0

I have some data at {1} This is a test data {2 } This is another data. Notice space after two which was given by error {3} This is one more data { 4} Another space error before number

I want to make all in their own line with correct format as {1} i.e no space before or after digit

I need a regex for that for Notepad++

Thanks

0

1 Answer 1

0
  • Ctrl+H
  • Find what: {\h*(\d+)\h*}
  • Replace with: \n{$1} or \r\n{$1} depending on platform
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

{           # open brace
\h*         # 0 or more horizontal spaces
(\d+)       # group 1, 1 or more digits
\h*         # 0 or more horizontal spaces
}           # close brace

Replacement:

\n          # linefeed, you can use \r\n for Windows EOL
{$1}        # content of group 1 (i.e. the digits) surrounded by braces

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

4
  • Thanks for the code. What is want is that the each numbers along with its sentence should come on separate line. For some reason I am not able to put it on separate line here. Its all showing in one continuous line in superuser.
    – Shahid
    Feb 17, 2022 at 18:02
  • Something like this: {1} This is a test data <br/> {2} This is another data. Notice space after two which was given by error <br/> {3} This is one more data <br/> {4} Another space error before number<br/>
    – Shahid
    Feb 17, 2022 at 18:11
  • @Shahid: See my edit.
    – Toto
    Feb 17, 2022 at 18:16
  • Thanks for the solution. It worked. I have accepted the anwer.
    – Shahid
    Feb 17, 2022 at 18:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .