Topic Options
#55142 - 08/04/17 02:45 PM Adv Search and Replace - Extract part of match
Uomo Del Ghiaccio Offline
OL Expert

Registered: 02/21/01
Posts: 666
I'm trying to reformat some text by using the Advanced Search and Replace plugin with a Regular Expression.

Basically I'm trying to remove the line breaks from the data where the pattern matches.

Data:
Quote:
Address:
1234 Main Street
Somewhere CA 99999
MRN: 0000009999


Search String:
Quote:
(Address:)\n([A-Za-z 0-9#,.-]{1,})\n([A-Za-z 0-9#,.-]{1,})\n(MRN:)


Replace With:
Quote:
$1$2 $3$4



Desired Results:
Quote:
Address:1234 Main Street Somewhere CA 99999
MRN: 0000009999


Settings:
  • Search whole file
  • Treat as regular expression
  • Match case


Unfortunately, it does not work even though the pattern shows a match on a online regular expression validator.

https://regex101.com/

Any assistance will be appreciated.
_________________________
Uomo Del Ghiaccio
--------------------

Top
#55143 - 08/04/17 03:13 PM Re: Adv Search and Replace - Extract part of match [Re: Uomo Del Ghiaccio]
Uomo Del Ghiaccio Offline
OL Expert

Registered: 02/21/01
Posts: 666
It appears that there was a conflict with a Regular Expression character \n and the PlanetPress control characters.

I had to change the pattern to this.

Quote:
(Address:)\r\012([A-Za-z 0-9#,.-]{1,})\r\012([A-Za-z 0-9#,.-]{1,})\r\012(MRN:)


And the output to this.

Quote:
$1$2 $3\n$4
_________________________
Uomo Del Ghiaccio
--------------------

Top