January 09, 2011 use of regex | ||||
---|---|---|---|---|
| ||||
Hello, After getting a MatchResult by calling match(source, engine): Seems that, if match has failed, calling result.hit() throws an assertion error. Then, how can I know whether match was successful? As there is always a matchResult object returned. I'm looking for a kind of success.failure flag on the matchResult. Note: this is for single match at start of source. I found this strange thingie in the online docs: struct RegexMatch(Range = string); ... bool chr(ref uint si, E c); Returns whether string s matches this. ??? Whether string s (which?) matches this (RegexMatch object): ??? And what are 'si' & 'c'? Denis -- -- -- -- -- -- -- vit esse estrany ☣ spir.wikidot.com |
January 09, 2011 Re: use of regex | ||||
---|---|---|---|---|
| ||||
Posted in reply to spir | spir Wrote: > Hello, > > After getting a MatchResult by calling match(source, engine): Seems that, if match has failed, calling result.hit() throws an assertion error. Then, how can I know whether match was successful? As there is always a matchResult object returned. I'm looking for a kind of success.failure flag on the matchResult. > > Note: this is for single match at start of source. You'll want to use: if(!m.empty) where m is your RegexMatch instance. > > I found this strange thingie in the online docs: > struct RegexMatch(Range = string); > ... > bool chr(ref uint si, E c); > Returns whether string s matches this. > ??? > Whether string s (which?) matches this (RegexMatch object): ??? > And what are 'si' & 'c'? File a bug. |
Copyright © 1999-2021 by the D Language Foundation