Regular Expressions 101

Community Patterns

Community Library Entry

4

Regular Expression
PCRE (PHP <7.3)

/
#Command handler #=============== #Start of the line ^ #Match the command name (?<cmd>[\w\d\-\_\?]+) #Catch as many parameters as possible (?<params> ( \ + (?<pre>[^\-\\\/\w\d\s\n\r]?) [^\"]*\k<pre> )* )? #Catch as many switches as possible and save them into group (?<switches> ( \ + #Switch starts with -- or - or / (?:\-\-|\-|\/) #Gotcha! [\w\d\_]+ )* )? #At the end of the line can be some spaces \ *$ #End of the line
/
gmx

Description

Handles commands like in CMD

Submitted by anonymous - 10 years ago