0

I'm trying to solve this problem with textwrangler but haven't figured the solution yet.

Any help will be much appreciated.

Suppose I have many emails like this one:

Goodbye

Welcome to the jungle and so on...with much more text...

Hello


How would I go to swap "Goodbye" and "Hello" without changing the entire text in between? Notice that the text between can change from email to email.


My guess is:

Search for:

(Goodbye)(?s).*?(Hello)

Replace with:

\2 \1

But it doesn't work.


I've also tried

Search for:

(Goodbye)|(Hello)

Replace with:

\2 \1

It doesn't work either

Mariano
  • 1
  • 2

2 Answers2

1

You can use the following, make sure you check Grep.

Find-Replace

WG1
  • 84
  • 6
0

You were actually pretty close. One way would be:

Searching for:

(Goodbye)(?s)(.*?)(Hello)

Replacing with:

\3\2\1

You'd encounter potentially unexpected effects, if the text included another Hello, which could be addressed by changing the search expression to:

(Goodbye)(?s)(.*)(Hello)

Please comment, if and as this requires adjustment / further detail.

Abecee
  • 2,365
  • 2
  • 12
  • 20