I searched but the other two threads on the same subject didn't really fit.
I have various bits of text that are encapsulated in parens, like this (xxx). I want to get them each on their own lines, like this:
(xxx)
(xxx)
(xxx)
The problem is, the file looks like this:
(xxx)(xxx)
(xxx)
(xxx)(xxx)
I've tried this code:
But that gives me:
(xxx)
(xxx)
(xxx)
(xxx)... and so on...
The ascii code is 0A 0D 0A 0D when the extra space shows up, but I have been unable as of yet to replace the two carriage returns with just one. I've tried using ASCII and I've tried using the "\n" character, but to no avail. Truthfully, I am not very familiar with RegExp.Replace and I'm probably using the wrong syntax, so if you know of the correct syntax I'd love to get another opinion.
Yes, one solution is to close the file, open it back up, and copy every non-blank line into a new file, but, well, yuk. I should be able to accomplish this without doing that using the RegExp object.
Any ideas?
Onwards,
Q-
I have various bits of text that are encapsulated in parens, like this (xxx). I want to get them each on their own lines, like this:
(xxx)
(xxx)
(xxx)
The problem is, the file looks like this:
(xxx)(xxx)
(xxx)
(xxx)(xxx)
I've tried this code:
Code:
Dim RegX, SearchPattern, ReplacedText, ReplaceString
Set RegX = NEW RegExp
SearchPattern = "\)"
ReplaceString = ")" & vbCrLf
RegX.Pattern = SearchPattern
RegX.Global = True
RegX.IgnoreCase = True
CurrentLine = RegX.Replace(CurrentLine, ReplaceString)
But that gives me:
(xxx)
(xxx)
(xxx)
(xxx)... and so on...
The ascii code is 0A 0D 0A 0D when the extra space shows up, but I have been unable as of yet to replace the two carriage returns with just one. I've tried using ASCII and I've tried using the "\n" character, but to no avail. Truthfully, I am not very familiar with RegExp.Replace and I'm probably using the wrong syntax, so if you know of the correct syntax I'd love to get another opinion.
Yes, one solution is to close the file, open it back up, and copy every non-blank line into a new file, but, well, yuk. I should be able to accomplish this without doing that using the RegExp object.
Any ideas?
Onwards,
Q-