How I can create a regular expression for the following problem:
I have a string,
name1=value1;name2=value2;.....;
Somewhere, there exists a pair,
"begin=10072011;"
I need, with regular expressions, to parse from the string all name=value; pairs, where the value is a number. However, I want to ignore the name begin
Currently I have the following regexp:
([\\w]+)=([\\d]+);
Mine selects the begin name. How can I change it to not include begin?
(?!begin)\b(\w+)=(\d+);This uses negative lookahead, so it will not match if the string starts with “begin”. The
\bis necessary so that the regex does not just skip the “b” and match “egin=…”.Note that when describing a regex you should only using a single backslash for escapes, although for some languages you will need to use double backslashes to escape the backslash.