I am new to regex,
Can anyone explain for me the patterns:
(<form[^\a]*</form>|<FORM[^\a]*</FORM>)
(method="[a-zA-Z]*|METHOD="[a-zA-Z]*)
Two great resources for RegExp: Debugexx and regular expressions 101
(<form[^\a]*</form>|<FORM[^\a]*</FORM>)
(method="[a-zA-Z]*|METHOD="[a-zA-Z]*)
From https://myregextester.com/index.php# (enter pattern in the field Match pattern
and make sure you have ticked Explain
. then click Submit):
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
<form '<form'
----------------------------------------------------------------------
[^\a]* any character except: '\a' (alarm) (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
</form> '</form>'
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
<FORM '<FORM'
----------------------------------------------------------------------
[^\a]* any character except: '\a' (alarm) (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
</FORM> '</FORM>'
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
'\r\n'
----------------------------------------------------------------------
( group and capture to \2:
----------------------------------------------------------------------
method=" 'method="'
----------------------------------------------------------------------
[a-zA-Z]* any character of: 'a' to 'z', 'A' to 'Z'
(0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
METHOD=" 'METHOD="'
----------------------------------------------------------------------
[a-zA-Z]* any character of: 'a' to 'z', 'A' to 'Z'
(0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
) end of \2
----------------------------------------------------------------------
'\r\n'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
[^\a]*
gets evaluated and means that it matches a character different from the special character \a
which is usually not printable but some kind of control character. Therefore that does not make much sense to me either. And the *
means that this part may appear 0 times, once or any other number.
– Byte Commander
Nov 20 '15 at 14:31
http://regexper.com/#(%3Cform%5B%5E%5Ca%5D*%3C%5C%2Fform%3E%7C%3CFORM%5B%5E%5Ca%5D*%3C%5C%2FFORM%3E)(method%3D%22%5Ba-zA-Z%5D*%7CMETHOD%3D%22%5Ba-zA-Z%5D*)%0A
– Byte Commander Nov 20 '15 at 14:17