how can format arbitrary string according flexible pattern? solution came using regular expressions, need 2 "patterns" (one search , 1 output). example: $str = '123abc5678"; desired output: 12.3ab-c5-67.8 i use pattern in variable (one user can define without knowledge of regular expressions) this: $pattern = '%%.%%%-%%-%%.%'; so user have use 2 different characters (% , .) a solution regex this: $str = '123abc5678'; $pattern_src = '@(.{2})(.{3})(.{2})(.{2})(.{1})@'; $pattern_rpl = "$1.$2-$3-$4.$5"; $res = preg_replace($pattern_src, $pattern_rpl, $str); //$res eq 12.3ab-c5-67.8 way complicated since user need define $pattern_src , $pattern_rpl. if string vary in length, more complex explain. yes, write function/parser builds required regular expressions based on simple user pattern %%.%%%-%%-%%.%. wonder if there "built in" way achieve php? thinking sprintf etc., doesn't seem trick. ideas? ...
when draw attributed string fixed line height text kit, characters aligned bottom of line fragment. while make sense on 1 line characters varying in size, breaks flow of text multiple lines. baselines appear decided largest descender each line. i've found article people behind sketch explaining exact problem in bit more detail , showing solution does, not explaining how achieved this. this want basically: when showing 2 lines large line height, result far ideal: the code i'm using: let smallfont = uifont.systemfont(ofsize: 15) let bigfont = uifont.systemfont(ofsize: 25) let paragraphstyle = nsmutableparagraphstyle() paragraphstyle.minimumlineheight = 22 paragraphstyle.maximumlineheight = 22 var attributes = [ nsfontattributename: smallfont, nsparagraphstyleattributename: paragraphstyle ] let textstorage = nstextstorage() let textcontainer = nstextcontainer(size: cgsize(width: 250, height: 500)) let layoutmanager = nslayoutmanager() textstorage.append(n...
i recorded macro this, , copied macro code , adapted how needed it. however, issue source formatting not kept when paste on new worksheet. step did miss? must selection.pastespecial right? below non-working syntax selection.autofilter activesheet.listobjects("db1.accdb").range.autofilter field:=1, criteria1:="pink" lastrow = 2 worksheets("sheet2").range("a65536").end(xlup).row next lastrow range("a1", "m" & lastrow).copy sheets.add after:=activesheet selection.pastespecial paste:=xlpasteallusingsourcetheme, operation:=xlnone, skipblanks:=false, transpose:=false range("a1").select activesheet.name = "pink" no need selection.pastespecial , normal copy method sufficient. sub copytest() '/ source destination '-------- ----------- sheet1.usedrange.copy sheet2.cells(1, 1) application.cutcopymode = false end sub << --this work c...
Comments
Post a Comment