Chesterkallas
Chesterkallas

Reputation: 37

Regex, replacing for newline with group replace

675185538end432 204 9/9 4709 908 2
343269172end430 3 43 9335 975 7
590144128end89 7 29 3-5-4 420 2
337460105end8Y5 7A 78 2 23
292484648end70 A53 03 9235 93

These are the strings that I am working with. I want to find a regex to replace the above strings as follows

675185538
432 204 9/9 4709 908 2
343269172
430 3 43 9335 975 7
590144128
89 7 29 3-5-4 420 2
337460105
8Y5 7A 78 2 23
292484648
70 A53 03 9235 93

Wherever end comes, \r\n should be introduced. The string before end is numeric and after end is alphanumeric with whiteline characters. I am using notepad++.

Upvotes: 0

Views: 402

Answers (2)

Bohemian
Bohemian

Reputation: 424983

To make the match strict, try this:

Find: ^(\d+)end(\w)
Replace: \1\r\n\2

This captures, then puts back via back references, the preceding number between start of line and "end" and the following digit/letter. This won't match "end" elsewhere.

Upvotes: 3

ben rudgers
ben rudgers

Reputation: 3669

Kludgery:

Find (\d\d\d\d\d\d\d\d\d)end(\d)

Replace \1\r\n\2

Find creates two capture groups:

  • each group is bounded by an ( and a )
  • one capture group matches exactly nine numerals
  • the other capture group matches exactly one numeral.

In the replace:

  • the first capture group is referenced with \1
  • and the second group with \2.

Upvotes: -1

Related Questions