Regex Question
I am working on a document that has had all the italics formatting removed and replaced with _foo_.
There are two catagories of words:
Those with characters after the word and no space.
Those with spaces after the word in the middle of a sentence.
I can find all occurrances with:
_(.+)_
I can replace those with characters after the word with:
\\i \1\\i0
(so there is no space after the word for characters like periods and commas)
I can replace those with spaces after the word with:
\\i \1 \\i0
(note the space between the 1 and first backslash so there is still a space there)
Example words:
_You_
(with a space after) and
_genocide_.
with a period after.
OK
So how can I efficiently find all occurrences but yet replace the ones with spaces after the word with a the corresponding "\\i \1 \\i0" and replace the ones with a character other than a space after the word with "\\i \1\\i0" in a single pass of the file?
I seem to need something like an "if then else " statement in regex.
Thanks for stopping by.
Free beer tomorrow.
Archon
|