Perl regular expression for inconsistent XML attributes



I am trying to write regular expression to capture from value field( string "male") for the two below lines using single regular expression



option selected="selected" value="***male***"

option value="***male***" selected="selected"


i have written some thing like,



option\s*?(?:value="(.+?)" selected="selected")|(?:selected="selected" value="(.+?)")


even though it is matching entire line from the file but "male" string is not captured. Please suggest.


No comments:

Post a Comment