1

I am using Notepad++ and want to replace a comma coming in between numbers with a dot. Like in below text file:

00:00:00,166 --> 00:00:03,999 In this section we will look at

should be like below:

00:00:00.166 --> 00:00:03.999 In this section we will look at

Thanks

HappyTown
  • 6,036
  • 8
  • 38
  • 51
Neeraj
  • 29
  • 1
  • 2

1 Answers1

9

Try this:

Find:

(?<=\d),(?=\d)

Replace with:

.

Here is a screenshot. Make sure you select Regular Expression radio button (pointed to by arrow). enter image description here Regex:

(?<=\d) - Positive look behind for a digit char
(?=\d) - Positive look ahead for a digit char

Demo:

https://regex101.com/r/iw1XsV/1

HappyTown
  • 6,036
  • 8
  • 38
  • 51
Mohammad Yusuf
  • 16,554
  • 10
  • 50
  • 78
  • maybe replace by `\1.\2` – baddger964 Feb 02 '17 at 07:37
  • @baddger964 Those are not capture groups. It's look ahead and look behind. – Mohammad Yusuf Feb 02 '17 at 07:38
  • @MYGz wouldyou elaborate on ?<= and ?= in your answer? – HappyTown Feb 02 '17 at 07:38
  • oh yes sorry my bad – baddger964 Feb 02 '17 at 07:38
  • @MYGz Thanks. I added a screenshot to your answer showing reg ex radio button on the replace dialog, in case the some one new to notepad++ and does not know they need to select reg ex. – HappyTown Feb 02 '17 at 07:46
  • @HappyTown Oh thanks for that :) – Mohammad Yusuf Feb 02 '17 at 07:58
  • Thank you MYGz. It still has some issue. It is searching and stopping at correct position but it is not replacing it with a dot. Rather it moves to the next when I click on Replace. – Neeraj Feb 02 '17 at 08:39
  • With Replace All command it is working fine. – Neeraj Feb 02 '17 at 08:44
  • @Neeraj When you click on Replace, It replaces and moves to next. Check the previous match, it would have been replaced by `.` – Mohammad Yusuf Feb 02 '17 at 09:35
  • Yeah there's something not right with this. I'm also using this for timestamps, but the other way around. It just replaces everything between those numbers. The semicolon gets replaced as well, replaced the semicolon with a dollar sign, the dollar sign gets replaced as well. So yeah, not quite right. This one works: https://stackoverflow.com/questions/49152588/replacing-comma-by-dot-only-in-numbers-in-a-texteditor-using-search-and-replace – Sven Cazier Jul 13 '22 at 22:17