Skip to content

Use Character-Enum without CharacterIn? #2

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]?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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