How do I find multiple matches with one regular expression?

Posted by christian studer on Stack Overflow See other posts from Stack Overflow or by christian studer
Published on 2010-05-12T14:53:14Z Indexed on 2010/05/12 15:14 UTC
Read the original article Hit count: 307

Filed under:
|

I've got the following string:

response: id="1" message="whatever" attribute="none" world="hello"

The order of the attributes is random. There might be any number of other attributes.

Is there a way to get the id, message and world attribute in one regular expression instead of applying the following three one after another?

/ message="(.*?)"/
/ world="(.*?)"/
/ id="(.*?)"/

© Stack Overflow or respective owner

Related posts about regex

Related posts about php