troubleshooting Question

Regex to match groups in any order

Avatar of Russ Suter
Russ Suter asked on
Regular ExpressionsC#
5 Comments1 Solution1950 ViewsLast Modified:
I have the following regular expression:
^\s*<\s*script\s*name\s*=\s*["](?<name>[^"]*)["]\s* platform\s*=\s*["](?<platform>[^"]*)["]\s*(deferred\s*=\s*["](?<deferred>[^"]*)["])?>\s*$
It matches fine against the following:
<script name="FOO" platform="all">
<script name="FOO" platform="all" deferred="yes">
However, I need it to match regardless of the order of the parameters so it should also match:
<script name="FOO" deferred="yes" platform="all">
 -- and --
<script platform="all" deferred="yes" name="FOO">
How do I rewrite the above Regex so that it will match each name-value pair regardless of what order they appear?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros