0

If I have a string "Param1=value1;Param2=value2;Param3=val3", how can I get the value between the substrings "Param2=" and the next semicolon (or end of string, whichever comes first)?"

4 Answers 4

3

/Param2=([^;]+)/

Sign up to request clarification or add additional context in comments.

Comments

1

"Param\d+=([^;]*)" will capture the contents between = and ; in group 1

Comments

0

You can either use a character class that excludes ; (as others have answered), or you can use a non-greedy match anything:

/Param2=(.*?);/

Comments

0

You can use this string to place all of the values into the Matches collection of the Regex class

string regex = "Param[0-9]*?=(?<value>.*?)(;|$)"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.