Replacing text in a text object
Posted: 2021-11-29 16:20:47
I've posted a question about a Find, but not with Replace, and somehow I can't seem to get it to work.
I have a text object, $text, containing a paragraph of text where the first word of each sentence is preceded by a one-or-two digit number, e.g.,
"5The next...". I want to remove all the numbers.
I have a one-line macro I've been using to perform this operation on the actual text of a document that looks like this:
Find and Replace @Text< \d+(\w[[:^punct:]])>, " \\1", 'Esa'
That works fine, although I no longer recall why I doubled the brackets. The thing about punctuation is there because (I think) the text may contain citation references in the form of "T-1.VI.4:1" and I do not want to replace anything in the reference. I've been trying to adapt it to work in the process of a longer macro that copies the text, does some stuff with it, and ends by trying to strip out the digits. In any case, this one-liner does the job I want done.
The code I've been trying to adapt for a text object is this:
$text = $text .findAndReplace " \d+(\w[[:^punct:]])", " \1", 'Esa'
What am I doing wrong? It is returning "()".Huh?
I have a text object, $text, containing a paragraph of text where the first word of each sentence is preceded by a one-or-two digit number, e.g.,
"5The next...". I want to remove all the numbers.
I have a one-line macro I've been using to perform this operation on the actual text of a document that looks like this:
Find and Replace @Text< \d+(\w[[:^punct:]])>, " \\1", 'Esa'
That works fine, although I no longer recall why I doubled the brackets. The thing about punctuation is there because (I think) the text may contain citation references in the form of "T-1.VI.4:1" and I do not want to replace anything in the reference. I've been trying to adapt it to work in the process of a longer macro that copies the text, does some stuff with it, and ends by trying to strip out the digits. In any case, this one-liner does the job I want done.
The code I've been trying to adapt for a text object is this:
$text = $text .findAndReplace " \d+(\w[[:^punct:]])", " \1", 'Esa'
What am I doing wrong? It is returning "()".Huh?