1

i got a table as txt.file with all the variables beeing seperated by ;.

Lets say i got 3 Variables: ID, Size and Comment.

My Data could look something like this:

1;1.5;hello. how are you?  
2;2.5;a comment.  
3;2.1;another comment.

Now i would like to replace the comma-sign from dot to comma.
If i use the standard search and replace function in my text-editor it will change all . to , without any problem. But i want to change only those . to , which are surrounded by numbers left side and right side.
1.5 should be changed to 1,5 but hello. how are you? should not be changed to hello, how are you?

I found a regular expression for searching only dots surroundet by numbers:

[0-9][\\.][0-9] 

Now i would like to replace those surroundet dots, but unfortunately it doesn't work yet. When replacing [0-9][\\.][0-9] by ,, 1.5 is changed to , only instead of 1,5.

Is there any nice way to use search and replace from a texteditor to solve this problem?

Thanks in advance!

Srdjan M.
  • 3,310
  • 3
  • 13
  • 34
TinglTanglBob
  • 627
  • 1
  • 4
  • 14
  • 2
    What is your text editor? – Sebastian Proske Mar 07 '18 at 13:09
  • Replacing ([\d])\.([\d]) with $1,$2 should work.Where group 1 is the number before '.' and group 2 is the number after '.'. Make sure you have regex option chosen in the search-replace editor. Or to make your example work (without \d), it should be: ([0-9])\.([0-9]) => $1,$2 – KKaar Mar 07 '18 at 13:12
  • Thanks for youre suggestions. Im using EditPlus. I've tried replacing ([0-9])\.([0-9]) by $1,$2 which ends up with 1.5 beeing replaced by $1,$2. It looks like the groups are not working. Maybe its a different sign than $ in EditPlus or something? – TinglTanglBob Mar 07 '18 at 13:31

1 Answers1

1

EditPlus does not support lookbehinds, so you need to use groups.

(\d)\.(\d)

Substitution: \1,\2

  • () Capturing group
  • \d matches a digit (equal to [0-9])
  • \1 \2 Capturing group 1. and group 2.

enter image description here

Srdjan M.
  • 3,310
  • 3
  • 13
  • 34