regexpliteral = "/" [ regexpatstart ] regexpsequence *( regexpalternative regexpsequence ) [ regexpatend ] "/" regexpoptions
regexpatstart = "^"
regexpatend = "$"
regexpoptions = 0*12( "i" / "m" / "s" / "x" / "e" / "A" / "D" / "S" / "U" / "X" / "j" / "u" )
regexpalternative = "|"
regexpsequence = 1*( (regexpclass / regexpgroup / regexpfactorword) [ regexpquantifier ] )
regexpfactorword = 1*( charfactor / regexpescape )
regexpgroup = "(" [ regexpgroupcapture ] regexpsequence *( regexpalternative regexpsequence ) ")"
regexpgroupcapture = "?" [ ":" / "|" / "=" / "!" / "<=" / "<!" / ">" / "#" / regexpnamedgroup ]
regexpnamedgroup = ( [ "P" ] "<" regexpgroupname ">" ) / ( "P'" regexpgroupname "'" )
regexpgroupname =  1*( ALPHA / DIGIT )
regexpclass = regexppredifinedclass / ( "[" [ regexpclassnegative ] 1*( regexppredifinedclass / regexpcharrange / regexpclassword ) "]" ) 
regexpclassnegative = "^"
regexppredifinedclass = "." / "\d" / "\D" / "\h" / "\H" / "\s" / "\S" / "\v" / "\V" / "\w" / "\W" / "[:alnum:]" / "[:alpha:]" / "[:ascii:]" / "[:blank:]" / "[:cntrl:]" / "[:digit:]" / "[:graph:]" / "[:lower:]" / "[:print:]" / "[:punct:]" / "[:space:]" / "[:upper:]" / "[:word:]" / "[:xdigit:]" / "[:^alnum:]" / "[:^alpha:]" / "[:^ascii:]" / "[:^blank:]" / "[:^cntrl:]" / "[:^digit:]" / "[:^graph:]" / "[:^lower:]" / "[:^print:]" / "[:^punct:]" / "[:^space:]" / "[:^upper:]" / "[:^word:]" / "[:^xdigit:]"
regexpcharrange = regexpcharstart "-" regexpcharend
regexpcharstart = charclass / regexpclassescape
regexpcharend = charclass / regexpclassescape
regexpclassword = 1*( charclass / regexpclassescape )
regexpquantifier = ( regexpquantifiersinglechar / regexpquantifierrange ) regexpquantifiergreed
regexpquantifiersinglechar = "?" / "*" / "+"
regexpquantifiergreed = [ "?" / "+" ]
regexpquantifierrange = "{" min [ "," [ max ] ] "}"

regexpclassescape = "\" (
     "a" / "e" / "f" / "n" / "r" / "t" /
     ( "c" ALPHA) /
     ( "x" HEXDIG HEXDIG) /
     ( "x" OCTAL OCTAL OCTAL) /
     charspecial / DIGIT )
regexpescape = "\" (
     "a" / "e" / "f" / "n" / "r" / "t" /
     ( "c" ALPHA) /
     ( "x" HEXDIG HEXDIG) /
     ( "x" OCTAL OCTAL OCTAL) /
     charspecialfactor / DIGIT )
charfactor =  ALPHA / DIGIT / "#" / "%" / "&" / "!" / "'" / "," / "-" / ":" / ";" / "<" / "=" / ">" / "@" / "_" / "`" / "~" / %x41 ; not /\[]{}()?+*|.^$ and %x41 is the caractere "
charclass = ALPHA / DIGIT / "{" / "}" / "(" / ")" / "$" / "+" / "*" / "?" / "|" / "#" / "%" / "&" / "!" / "'" / "," / ":" / ";" / "<" / "=" / ">" / "@" / "_" / "`" / "~" / %x41 ; not /\[]^-
charspecialfactor =  "[" / "\" / "]" / "^" / "/" / "{" / "}" / "(" / ")" / "?" / "+" / "*" / "|" / "." /"^" / "$" / " "
charspecial =  "-" / "[" / "\" / "]" / "^" / " "

min = 1*DIGIT
max = 1*DIGIT

HEXDIG = DIGIT / %x61-65 / %x41-45
DIGIT = %x30-39
OCTAL = %x30-37
ALPHA = %x41-5A / %x61-7A
