Regular Expressions for begineers

Welcome Forums General PowerShell Q&A Regular Expressions for begineers

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 10 months ago.

  • Author
    Posts
  • #21334

    Participant
    Points: 0
    Rank: Member

    Totally bemused by regular expressions

    i.e. "book" -match 'i?' ...what is the point ??

    The PowerShell help says of '?'...... "Matches one instance of the preceding character."

    But the above example returns a "True"

    I must be missing something !!

  • #21335

    Moderator
    Points: 0
    Rank: Member

    The question mark quantifier makes the preceding token optional in your example the i. You could write "book" -match " to get the same result.

    Check out http://www.regular-expressions.info/optional.html for more examples on the question mark quantifier.

  • #21336

    Participant
    Points: 0
    Rank: Member

    Thanks Daniel.

    I get it now.

    The examples given in the MS Powershell online help do not always give particularly good example of regex from a beginners perspective.

    Mind you, even the online help is a great deal better than some manuals I could mention !

The topic ‘Regular Expressions for begineers’ is closed to new replies.