Sample RegExp

A swapping-ground for Regular Expression syntax

Sample RegExp

Postby Admin » Sun Mar 19, 2006 5:02 pm

I've just been asked to solve this problem, so here goes:

Suppose I have 100 files named in the same manner as the following three:

001 G61138 ElPaisanoHotel,MarfaTX20051221.jpg
002 SD0337 PresidioCoCourthouse,MarfaTX20051221.jpg
003 G14338 OldHouse,MarfaTX20051221.jpg

I would like to move the second group of alphanumeric characters (i.e., G61138, SD0337, G14338, etc.) in each of 100 filenames to the end of the filename, as follows:

001 ElPaisanoHotel,MarfaTX20051221 G61138.jpg
002 PresidioCoCourthouse,MarfaTX20051221 SD0337.jpg
003 OldHouse,MarfaTX20051221 G14338.jpg

Here's my solution:

Match: (\d\d\d\s)([A-Za-z0-9]*\s)(.*)
Replace: \1\3 \2

Site Admin
Posts: 1465
Joined: Tue Mar 08, 2005 8:39 pm

Postby aban » Mon Apr 16, 2007 9:14 am


This code work great, really useful,

Tahnks. :wink:

software reviews
Posts: 1
Joined: Mon Apr 16, 2007 3:52 am

Return to Regular Expressions