I was fortunate to learn some bits of regex/grep from helpful people on this list who not only showed an answer to a question but explained what was happening. While this search/replace using grep is quite simple, it’s not always obvious to everyone.
> On May 8, 2022, at 1:36 PM, Dave Simpson <
quar...@gmail.com> wrote:
>
> You want to do a GREP search, with search string like this:
>
> ^(2 PLAC)(.*)$
>
> And you want to replace with this:
>
> \1\2 England
>
> That’s it. Try it.
>
In the search pattern:
^ means start at the beginning of a line
(2 PLAC) parentheses bracket the search text and “remembers" it. In this case, it is known characters. Grep lets you search for unknown/partially known characters too.
(.*) second parentheses uses “.” As any character except newline or carriage return. The asterisk expands that to zero or more characters.
$ means the end of the line.
The replacement is
\1 first parentheses “remembered” pattern
\2 follow that with the second
England end the replacement with a space and then the literal text “England”
That’s mostly this grep/replace. You know the BBEdit Manual has lots more.
Bucky