Ridiculously simple regex that refuses to work

A swapping-ground for Regular Expression syntax

Ridiculously simple regex that refuses to work

Postby dis astranagant » Mon Sep 23, 2013 7:52 pm

I have a folder full of 1.jpg 2.jpg ... 40.jpg that need leading zeros on the single digit names. I've tried using (\b\d\.jpg) replacing with 0\1 but it's giving me some strange results. Instead of getting 01.jpg out of it I'm getting 01.jpg.jpg.
dis astranagant
 
Posts: 1
Joined: Mon Sep 23, 2013 7:36 pm

Prefix final digit if preceeded by word-separator (or null)

Postby truth » Tue Sep 24, 2013 6:51 am

Sounds like you've got some settings to verify:
Options/Ignore/FileExtension=Checked, 1Regex IncludeExt=UNchecked, 11Extensions=Same
Also, since you spec'd \b word-separator, I assumed that filenames vary more than those listed

Since you spec'd .extension in match, I'll stay with that format
To rename .jpg's ending either as: #.jpg (even if nothing precedes it) or WordSeparator#.jpg
So that:
1.jpg -----------> 01.jpg
11.jpg ---------> (not matched for renaming)
Name 1.jpg ---> Name 01.jpg
Name-1.jpg ---> Name-01.jpg
Name 11.jpg --> (not matched for renaming)

1Regex
^(.*[^0-9,\w])*(\d.jpg)$
\10\2
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions