example text
this text left alone ##{class1}{arg1;arg2;arg3}## other text , thingie ##{class2}{]## currently i'm using '/\#\#\{(?p<class>.+)\}\{(?p<args>.+)\}\#\#/i' match it, problem when regex occurs multiple times, because match text between 2 matched patterns.
and result of regex ##{classname1}{arg1;arg2;arg3}## other random ##{class2}{}##.
is there more elegant way extract ##{class1}{arg1;arg2;arg3}## , ##{class2}{]## string , replace them output coresponding classes?
i'm using replace them output class1 , class2 arguments inbetween second set of {}
note: if second set of {} empty means no arguments passed class name in first set of {}
the issue .+ "greedy" — consume every character possibly can, long rest of pattern can still resolve.
the dirty generic solution .+? match fewest characters necessary satisfy rest of pattern, , work in case.
but it's preferable write more specific .+ anyway. in case, [^}]+ work? is, between { , } symbols, can have number of characters aren't closing }.
Comments
Post a Comment