regex replace all instances of a character except for the last one?

Advanced Renamer forum
#1 : 10/01-24 16:13
Chad Briggs
Chad Briggs
Posts: 3
Hi! Two questions for the community:
Is there a good online guide for regex that specifically works with AR? I can find regex code examples, but they never seem to work properly inside of AR? A regex for dummies 101?

Secondly, on to the more specific question:
I have this string my_file_name_0000.png

I want to replace all the underscores with hyphens except the last one:
my-file-name_0000.png

Any tips on how to pull that off with a replace function and checking 'use regular expressions'? (note: diff files will have diff numbers of underscores in diff locations, so nothing consistent)


10/01-24 16:13
#2 : 10/01-24 20:29
Miguel
Miguel
Posts: 136
Reply to #1: Hi,
I have achieved it in two steps.
1
Text to be replaced: _
Replace with: -
2
Text to be replaced: [-](?=[^-]*$)
Replace with: _
Use regular expresion.


10/01-24 20:29