Reputation: 11125
Using Visual Studio 2010 I would like to do a project level regular expression replace as below.
Find: #region {any string here}
Replace: #region - string from above -
I tried the below:
region\s'{[^]+}'
region '{[^]+}'
region {:q}
But the IDE complains about an incorrect pattern. How can I fix this?
Upvotes: 8
Views: 8203
Reputation: 2915
Try:
Search: {\#region:b+}{.*}
Replace: \1 - \2 -
If you're specifically searching for the '{' and '}',
Search: {\#region:b+}\{{.*}\}
With quotes:
Search: {\#region:b+}{'.*'}
To remove quotes:
Search: {\#region:b+}'{.*}'
Upvotes: 5
Reputation: 14030
Ahhh, Visual Studio regexes... They shouldn't be called a regex since they diverge to much of what is "standard"
I fired up VS and after some trial and error this works:
search:
\#region \{{.*}\}
replace:
#region - \1 -
Upvotes: 8