Forum Discussion
SOLVED: Find and replace (using wildcards) text at the end of lines in tables
No. As I have shown, it's a letter followed by a dot, after the date [г. = y.(ear) in our language (Bulgarian)], therefore ([0-9])г.(^13) or ([0-9]) г.(^13)
depending on whether there is a space between the year and the г. or not.
Only I can't find a way to do it in tables, because lines there don't end with a paragraph, as explained in my question.
And if I was to replace any г. with nothing, then I would lose the period sign when it happens to be at the end of sentences, which, obviously, I'm trying to avoid, hence г.(^13)
In the previous 2 steps of the replacement, I replace
([0-9])г. ([!А-Я])
([0-9]) г. ([!А-Я])
([0-9]) г.([!А-Я ^13])
with \1 \2
then
([0-9])г. ([А-Я])
([0-9]) г. ([А-Я])
([0-9]) г.([А-Я])
with \1. \2
and finally
([0-9])г.(^13)
([0-9]) г.(^13)
with \1.\2
Thank you.
- Mar 12, 2022How about first using a Wildcard replace to replace
([0-9]{2,4})r.
with
\1 r.
to put a space before the r. if there isn't one. Then use an ordinary replace to replace a space followed by r and a period (.) with nothing.
I assume that it is unlikely that in ordinary text, you would have a sentence ending with a space followed by r and a period- FunfunfanMar 12, 2022Copper Contributor
Every line that ends with a date would end with a г.
I was born in 1982 г.
My father was born in 1948 г.So if it's in the normal text, I can easily process it, because there's this specific character ^p or ^13 that I can use to limit my Find&Replace operations to.
Whereas in a table, there's no paragraph at the end of the last line in the cell.
- Mar 12, 2022
You do not need to include the ^p or ^13 UNLESS you do NOT want to remove the r. from
I was born in 1982 r. so I am now 40.
or
I was born in 1982r. so I am not 40.If you want to leave the r. alone in those cases, you could do what you want by using VBA.
Selection.HomeKey wdStory
With Selection.Find
Do While .Execute(FindText:="[0-9]{2,4}r.", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=True) = True
If Selection.Information(wdWithInTable) = True Then
Selection.Text = Left(Selection.Text, Len(Selection.Text) - 2)
End If
Selection.Collapse wdCollapseEnd
Loop
End With
Selection.HomeKey wdStory
With Selection.Find
Do While .Execute(FindText:="[0-9]{2,4} r.", Forward:=True, _
MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=True) = True
If Selection.Information(wdWithInTable) = True Then
Selection.Text = Left(Selection.Text, Len(Selection.Text) - 3)
End If
Selection.Collapse wdCollapseEnd
Loop
End With