Replace text in search results?
-
In the find box, using “Find all in Current Document” displays those results in lines in “Search Results”. Is there any way to either directly edit these lines in the search results tab, and/or, find and replace text only within those search results?
-
@Steve-Smith-0 said in Replace text in search results?:
Is there any way to either directly edit these lines in the search results tab, and/or, find and replace text only within those search results?
Not as you might think. However if you were to read the online manual, specifically the search result area here (see paragraph which includes …Double-clicking with the mouse…) you will see that it links to the main editor window and allows you to quickly move around the file/tab based on the search results to edit that text you were searching on.
Terry
-
@Steve-Smith-0
I don’t know what exactly you’re trying to do, but one generic way to find/replace only in lines that match some specification is to do regex-replace with positive forward lookahead from the start of each line for the first constraint.For example, if you want to find/replace all instances of the letter
c
withd
on lines that containab
, the regex/replace(?-si)^(?=.*ab).*\Kc
ford
would convertabc cab ccc dd ab c c ab
to
abd dab ccc dd ab d d ab
-
My regex to find/replace
c
withd
in lines containingab
was wrong, here’s the improved version:
Replace(?-si)(?:^(?=.*ab)|(?!\A)\G).*?\Kc
withd
Should convertabc cab ccc z a c dd ab c c abcccc
to
abd dab ccc z a c dd ab d d abdddd
whereas the regex in my previous post would only convert one
c
at a time from the last line.