Regular Expression Help

Associate
Joined
7 Nov 2005
Posts
746
Location
Southampton, UK
Hi guys,

I need to do some string manipulation, I need to replace all instances of X within a string with Y where X is a NOT within a pair of single quotation marks.

e.g.

This is a sentence with the word quoted both 'quoted' and unquoted
X = quoted
Y = chips
After replacement should read
This is a sentence with the word chips both 'quoted' and unchips

Note the 'quoted' is untouched.

I've really got no idea how to do this... :(

Edit: I'm using .NET 1.1, this can not be changed :( stupid legacy systems.
 
(?<unquotedWord>(?<!')\b\w+\b(?!')) will give you all the unquoted words in a string. Not really up on how the replace would work.
 
Back
Top Bottom