I have to populate a shop's images and been provided with folders of images which arein the format, eg BRL0368 Side.jpg
, 5510 Dura Guard Carpet.jpg
.
Now what I want to do is chop all those down so I can just try and match up in excel the part numbers eg "BRL0368.jpg"
, "5510.jpg"
I have something called regex renamer which takes a regex match & a replacement value - and will recurse through a folder etc and batch rename.
Unfortunately at the moment I don't have much expereince with regex so it's a bit confusing for me - I tried many different options but not having much luck.
How do I say grab the first part (alpha & digit) up to the first space and dump the rest?
this is what I have been trying ([^\s]+)
- I also tried \w
etc.
It may depend on the language used, but this should work :
/^[^\s]+/
To capture the first word and the last (the extension) you can use this expression :
/(^[^\s]+).*?(\.\w+)$/
Here's a javascript demo to clear things up : http://jsfiddle.net/eDB2z/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With