Skip to content

Use Character-Enum without CharacterIn? #2

@Birgos

Description

@Birgos

Following expression: (?<First>(?:2[0-4]\d|25[0-5]|[01]?\d\d?))\.(?<Second>(?:2[0-4]\d|25[0-5]|[01]?\d\d?))\.(?<Third>(?:2[0-4]\d|25[0-5]|[01]?\d\d?))\.(?<Fourth>(?:2[0-4]\d|25[0-5]|[01]?\d\d?))

My result:

var ipAdress = new Magex().Alternative(
    Magex.New()
              .Character('2')
              .CharacterIn('0', '-', '4')
              .CharacterIn(Characters.Numeral),
    Magex.New()
              .String("25")
              .CharacterIn('0', '-', '5'),
    Magex.New()
              .CharacterIn('0', '1').Repeat.AtMostOnce()
              .CharacterIn(Characters.Numeral)
              .CharacterIn(Characters.Numeral).Repeat.AtMostOnce());

var expression = new Magex().CaptureAs("First", _ipAdress)
   .Character('.')
   .CaptureAs("Second", ipAdress)
   .Character('.')
   .CaptureAs("Third", ipAdress)
   .Character('.')
   .CaptureAs("Fourth", ipAdress);

Is there a way to use the enums of Characters directly without encapsulating them inside a CharacterIn call? Getting \d instead of [\d]?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions