CSharpVerbalExpressions
CSharpVerbalExpressions copied to clipboard
AnythingBut followed by a Maybe should be ignored
When you have an AnythingBut
followed by a Maybe
assuming the value of Maybe
isn't the value of AnythingBut
then the Maybe
should be ignored.
For instance the two following are semantically the same:
var verbEx = VerbalExpressions.DefaultExpression
.StartOfLine()
.Then( "http" )
.Maybe( "s" )
.Then( "://" )
.Maybe( "www." )
.AnythingBut( " " )
.EndOfLine();
var verbEx = VerbalExpressions.DefaultExpression
.StartOfLine()
.Then( "http" )
.Maybe( "s" )
.Then( "://" )
.Maybe( "www." )
.AnythingBut( " " )
.Maybe("/")
.EndOfLine();
Both of the above should output ^(http)(s)?(://)(www\.)?([^\ ]*)$
because the AnythingBut
is greedy and will capture whatever is in the Maybe
.