Forum Moderators: coopster
I am using a PCRE regex function to get parts of a string.
my current pattern is:
$pattern = "/<([^\s]+)\s+([^\s]+)\s+([^\s]+)\s*><\/a>/i";
and my string is:
$string = '<a href="123" href="456" ></a>';
This will match.
The problem is that ([^\s]+)\s+ in the pattern is repeated.
in the string it is:
([^\s]+)\s+([^\s]+)\s+
How can I change my pattern so that ([^\s]+)\s+ does not need to be repeated like this.
As I am capturing the output, I can not use (([^\s]+)\s+)+ as it will only capture the last string match, not all of them.
Thanks,
Bud Smith
aelement. Or are you trying to accomplish something specific, such as locating duplicate href attribute settings in that particular element?
The reason I ask is you may be better off using something like:
$array = explode(' ', $string);Just a thought.