Skip to content

AnythingBut followed by a Maybe should be ignored #23

@jduncanator

Description

@jduncanator

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions