Suppose I had the following string I wanted to run a Regular expression on:
This is a test string with "quotation-marks" within it.
The "problem" I am having, per-se, is "knowing" which "quotation-marks"
go with which words.
Now, suppose I wanted to replace all the -
characters between the quotation marks with, say, a space. I was thinking I could do so with a regex looking as follows:
Find What: ("[^"]*?)(-)([^"]*?")
Replace With: $1 $3
The problem I'm having is that using this pattern, it does not take into account whether a quotation mark was opening or closing the statement.
So, in the example above, the -
character in per-se
will be replaced by a space since it is between 2 quotation marks, but between a closing and an opening mark - When I specifically want to look within the text between an opening and a closing mark.
How do you account for this in such a regular expression?
I hope this makes sense.
I'm using VB / C# Regex.
Just to complete the question (and hopefully elaborate a bit more if necessary), the end result I would like to get would be:
This is a test string with "quotation marks" within it.
The "problem" I am having, per-se, is "knowing" which "quotation marks"
go with which words.
Thanks!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…