[Pyparsing] Anchoring py.Regex
Brought to you by:
ptmcg
From: thomas_h <th...@gm...> - 2011-08-31 09:50:43
|
Hi, first off, thanks for pyparsing - great stuff. Using pyparsing 1.5.5, I'm struggling with using the ^ anchor in a regular expression passed to py.Regex. E.g. if my input string is comment = ''' /** * Checks if a class is compatible to the given mixin (no conflicts) * * @param mixin {Mixin} mixin to check * @param clazz {Class} class to check * @throws an exception when the given mixin is incompatible to the class * @return {Boolean} true if the mixin is compatible to the given class */ ''' I want to match in my grammar the " *" prefix that precedes each payload in a line (except the first and last, of course). I tried py.Regex(r'^\s*\*', re.M).searchString(comment) which gives me just ([], {}). Leaving away the ^ anchor, I get all expected matches. Also using the $ anchor, e.g. in py.Regex(r'k$', re.M).searchString(comment) it seems to work and I get all expected matches (from the "... check" lines). So what am I doing wrong with ^? Thomas |