Link to home
Start Free TrialLog in
Avatar of D B
D BFlag for United States of America

asked on

Visual Studio Replace to Change Delimiters

I have code open and want to change string delimiters from single quotes to square brackets using Visual Studio I want to search for the pattern (double quotes are NOT part of the string/pattern):
" AS 'something here'"

and replace it with: 

" AS [something here]"

So basically looking for a single space the word AS, another space, a single quote, a string, another single quote and want to replace the first quote with [ and the second with ]. I want to do this within the search/replace box (Ctrl-H) in VS with regualar expressions selected. I'm a LONG way from being a RegEx expert so looking for some help. Might mention, if not adding a lot of complication to the search string, the space surrounding the AS keyword could be more than one space or could be tab(s). Multiple spaces and/or tab characters can be replaced with just a single space.


TIA

Avatar of D B
D B
Flag of United States of America image

ASKER

So, I think this is what I want in my Find box: \sAS\s+'.*' but not sure how to get a 'placeholder' for what is between the quotes so I can use it in the Replace box. I've seen examples that use $1 as the placeholder in Replace (e.g. " AS [$1]" but not sure how to 'capture' that in the search box.
ASKER CERTIFIED SOLUTION
Avatar of D B
D B
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of louisfr
louisfr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial