www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - use of regex

reply spir <denis.spir gmail.com> writes:
Hello,

After getting a MatchResult by calling match(source, engine): Seems that, i=
f match has failed, calling result.hit() throws an assertion error. Then, h=
ow can I know whether match was successful? As there is always a matchResul=
t object returned. I'm looking for a kind of success.failure flag on the ma=
tchResult.

Note: this is for single match at start of source.

I found this strange thingie in the online docs:
struct RegexMatch(Range =3D 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 =E2=98=A3

spir.wikidot.com
Jan 09 2011
parent Jesse Phillips <jessekphillips+D gmail.com> writes:
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.
Jan 09 2011