vsav
vsav

Reputation: 31

append an existing string with notepad++

I have multiple text files opened in Notepad++. And each file is like this.

[11]
[205]
[77]

I'm searching for [[0-9]+]\s in regex mode, but I don't know how to replace it to the output I need.

And I want to append a string like this in all opened files, like this.

[11.0]
[205.0]
[77.0]

I'm searching for \[[0-9]+\]\s in regex mode, but I don't know how to replace it to the output I need.

How to do this?

Upvotes: 2

Views: 477

Answers (2)

Toto
Toto

Reputation: 91415

  • Ctrl+H
  • Find what: \[\d+\K(?=])
  • Replace with: .0
  • CHECK Wrap around
  • CHECK Regular expression
  • Replace all

Explanation:

\[      # openning squarre bracket
\d+     # 1 or more digits
\K      # forget all we have seen until this position
(?=])   # positive lookahead, make sure we have a closing squarre bracket after

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Upvotes: 3

CinCout
CinCout

Reputation: 9619

Use this regex for searching:

(\[\d+)(\])

and the following for replacing:

\1.0\2

You need to escape [ and ] in your pattern via a \ since they have a special meaning in the regular expression world.

Upvotes: 1

Related Questions