Q: regex: How do I match for anything BUT a given value as well as another condition I have a string that I'm regex matching for a list of matching values in part of the string, which works fine, but I want to further restrict the regex to also match a different part of the string for anything BUT a given value.
The regex I'm using for the first part that work is:
ControlListOptions.match(new RegExp("<option scriptstepdatatypeid='(" + enumControlType.GenericList + "|" + enumControlType.SalutationList + "|" + enumControlType.StateList + "|" + enumControlType.StreetTypeList + ")' stepid='" + stepid + "' .*?>(.*?)<\/option>","gi"))

However, I want to restrict it to data that has a value attribute of anything BUT a given value.
I tried by using something like:
ControlListOptions.match(new RegExp("<option scriptstepdatatypeid='(" + enumControlType.GenericList + "|" + enumControlType.SalutationList + "|" + enumControlType.StateList + "|" + enumControlType.StreetTypeList + ")' stepid='" + stepid + "' value='(.(?!4642))*'>(.*?)<\/option>","gi"))

But that gives me even more matches than the first regex, so that seems to widen the matching criteria somehow.
The ControlListOptions variable has the following value:
<option scriptstepdatatypeid='28' stepid='19' value='342'>19 : First Step : 342 : First Field</option><option scriptstepdatatypeid='20' stepid='19' value='1299'>19 : First Step : 1299 : On a scale of 1 to 10, how satisfied are you with our service?[1,10,1,10]</option><option scriptstepdatatypeid='1' stepid='19' value='1300'>19 : First Step : 1300 : Yes No</option><option scriptstepdatatypeid='23' stepid='19' value='1301'>19 : First Step : 1301 : Address</option><option scriptstepdatatypeid='5' stepid='19' value='4641'>19 : First Step : 4641 : Parent List[1,2,3,1140,4,5,61,64]</option><option scriptstepdatatypeid='5' stepid='19' value='4642'>19 : First Step : 4642 : Generic List 1</option><option scriptstepdatatypeid='3' stepid='19' value='4643'>19 : First Step : 4643 : Text Area</option><option scriptstepdatatypeid='25' stepid='19' value='4644'>19 : First Step : 4644 : Numeric</option><option scriptstepdatatypeid='26' stepid='19' value='4645'>19 : First Step : 4645 : List Builder</option><option scriptstepdatatypeid='5' stepid='19' value='4646'>19 : First Step : 4646 : List 1[A,B,C,D,E,F]</option><option scriptstepdatatypeid='27' stepid='19' value='4647'>19 : First Step : 4647 : DateTime</option><option scriptstepdatatypeid='6' stepid='19' value='4648'>19 : First Step : 4648 : Date</option><option scriptstepdatatypeid='14' stepid='19' value='4649'>19 : First Step : 4649 : Phone number</option><option scriptstepdatatypeid='29' stepid='19' value='4650'>19 : First Step : 4650 : Grid</option><option scriptstepdatatypeid='2' stepid='19' value='4651'>19 : First Step : 4651 : Client Company ID</option><option scriptstepdatatypeid='2' stepid='21' value='341'>21 : Enter Data : 341 : Test Field</option><option scriptstepdatatypeid='24' stepid='27' value='1988'>27 : Add Structure : 1988 : Choose Structure(s)</option><option scriptstepdatatypeid='2' stepid='1405' value='1302'>1405 : Lounge : 1302 : Option Field</option><option scriptstepdatatypeid='2' stepid='1406' value='1303'>1406 : Kitchen : 1303 : Option Field</option><option scriptstepdatatypeid='2' stepid='1407' value='1304'>1407 : Bathroom : 1304 : Option Field</option><option scriptstepdatatypeid='2' stepid='1409' value='1305'>1409 : Add Structure or Continue : 1305 : Estimated Cost</option><option scriptstepdatatypeid='1' stepid='1409' value='1306'>1409 : Add Structure or Continue : 1306 : Walls</option><option scriptstepdatatypeid='21' stepid='1410' value='1161'>1410 : Dropout Step : 1161 : PDF Link</option><option scriptstepdatatypeid='2' stepid='1412' value='1298'>1412 : Don't enter data : 1298 : Skipped Field</option>

And I would expect the following as the result:
["<option scriptstepdatatypeid='5' stepid='19' value='4641'>19 : First Step : 4641 : Parent List[1,2,3,1140,4,5,61,64]</option>", "<option scriptstepdatatypeid='5' stepid='19' value='4646'>19 : First Step : 4646 : List 1[A,B,C,D,E,F]</option>"]

Any ideas?
UPDATE:
I was pretty sure that the answer supplied of using value='(?!4642).*' had worked, but I've since found that it is matching too many values.  The regex I'm using now ends up as:
<option scriptstepdatatypeid='5|8|9|16' stepid='19' value='(?!4642).*'>(.*?)</option>

and the matches that it is returning are:
["<option scriptstepdatatypeid='5' stepid='19' value='4641'>19 : First Step : 4641 : Parent List[1,2,3,1140,4,5,61,64]</option><option scriptstepdatatypeid='5' stepid='19' value='4642'>19 : First Step : 4642 : Generic List 1</option><option scriptstepdatatypeid='3' stepid='19' value='4643'>19 : First Step : 4643 : Text Area</option><option scriptstepdatatypeid='25' stepid='19' value='4644'>19 : First Step : 4644 : Numeric</option><option scriptstepdatatypeid='26' stepid='19' value='4645'>19 : First Step : 4645 : List Builder</option><option scriptstepdatatypeid='5' stepid='19' value='4646'>19 : First Step : 4646 : List 1[A,B,C,D,E,F]</option><option scriptstepdatatypeid='27' stepid='19' value='4647'>19 : First Step : 4647 : DateTime</option><option scriptstepdatatypeid='6' stepid='19' value='4648'>19 : First Step : 4648 : Date</option><option scriptstepdatatypeid='14' stepid='19' value='4649'>19 : First Step : 4649 : Phone number</option><option scriptstepdatatypeid='29' stepid='19' value='4650'>19 : First Step : 4650 : Grid</option><option scriptstepdatatypeid='2' stepid='19' value='4651'>19 : First Step : 4651 : Client Company ID</option><option scriptstepdatatypeid='2' stepid='21' value='341'>21 : Enter Data : 341 : Test Field</option><option scriptstepdatatypeid='24' stepid='27' value='1988'>27 : Add Structure : 1988 : Choose Structure(s)</option><option scriptstepdatatypeid='2' stepid='1405' value='1302'>1405 : Lounge : 1302 : Option Field</option><option scriptstepdatatypeid='2' stepid='1406' value='1303'>1406 : Kitchen : 1303 : Option Field</option><option scriptstepdatatypeid='2' stepid='1407' value='1304'>1407 : Bathroom : 1304 : Option Field</option><option scriptstepdatatypeid='2' stepid='1409' value='1305'>1409 : Add Structure or Continue : 1305 : Estimated Cost</option><option scriptstepdatatypeid='1' stepid='1409' value='1306'>1409 : Add Structure or Continue : 1306 : Walls</option><option scriptstepdatatypeid='21' stepid='1410' value='1161'>1410 : Dropout Step : 1161 : PDF Link</option><option scriptstepdatatypeid='2' stepid='1412' value='1298'>1412 : Don't enter data : 1298 : Skipped Field</option>"]


A: If I've understood your requirement correctly, I'd recommend using a negative lookahead - stepid='(?!step3).*' (match every step except "step3")
E.g.
For the following samples:
<option scriptstepdatatypeid='one' stepid='step1' att2='foo' >barbarbar</option>
<option scriptstepdatatypeid='two' stepid='step2' att2='foo' >barbarbar</option>
<option scriptstepdatatypeid='three' stepid='step3' att2='foo' >barbarbar</option>
<option scriptstepdatatypeid='four' stepid='step4' att2='foo' >barbarbar</option>

The follow regex matches all steps except "step3":
<option scriptstepdatatypeid='(one|two|three|four)' stepid='(?!step3).*' .*?>(.*?)</option>

Test it out here -> http://regexpal.com
