I try (without success) to make a regex for find a submit button even if button code is in one two or more lines.
I use now this patter
/<(button|input)(.*type=['\"](submit|button)['\"].*)?>/i
and works fine if the button code is in one line
<input type="submit" name="mybutton" class="button_class" value="Submit" title="Click Me" />
I want to make it work if my button code look like
<input type="submit" name="mybutton"
class="button_class" value="Submit"
title="Click Me" />
Thanks
Don’t use a regular expression to parse HTML.
RegEx match open tags except XHTML self-contained tags
Learn xpath, and use a parser.
EDIT Added some code to insert before.