RegEx with 'Include Ext.' appends original extension

A swapping-ground for Regular Expression syntax

RegEx with 'Include Ext.' appends original extension

Postby pm771 » Fri Jan 22, 2010 11:59 pm

Hi

I must be doing something wrong but can't figure it out.

Match:
Code: Select all
(106)-([\d][\d])(..)(\.).([A-Z]).

Replace:
Code: Select all
1006\3\4\5\2


For 106-01OH.DTS it gives me 1006OH.T01.DTS, while I expect 1006OH.T01

What puts the second extension into the result? :?:

TIA, Eugene
pm771
 
Posts: 8
Joined: Tue Sep 02, 2008 10:58 pm

Re: RegEx with 'Include Ext.' appends original extension

Postby pm771 » Sat Jan 23, 2010 12:04 am

I set box 11 'Extension' to Remove and got the desired result.

Is it the way I was supposed to do it?
pm771
 
Posts: 8
Joined: Tue Sep 02, 2008 10:58 pm

Re: RegEx with 'Include Ext.' appends original extension

Postby Stefan » Sat Jan 23, 2010 2:09 am

pm771 wrote:Hi

I must be doing something wrong but can't figure it out.

Match:
Code: Select all
(106)-([\d][\d])(..)(\.).([A-Z]).

Replace:
Code: Select all
1006\3\4\5\2


For 106-01OH.DTS it gives me 1006OH.T01.DTS, while I expect 1006OH.T01

What puts the second extension into the result? :?:

TIA, Eugene


Hi Eugene, i think this must be an bug.
Since your regex don't advice to replace with the extension, the extension should not be there.
It seams as the program author add the extension automatically because of the chosen option "Include Ext." to the Replace-field too,
where it should be in the Match-field only, because the user decide what to do,... what to match and what to replace with.
But you find an good work around. Be happy with it :D


FROM:
106-01OH.DTS
TO:
1006OH.T01
But results badly in:
1006OH.T01.DTS

RegEx(1)
Match: (106)-([\d][\d])(..)(\.).([A-Z]).
Repla: 1006\3\4\5\2
[X] Include Ext.

Code: Select all
106-01OH.DTS
106  -    01     OH   . D   T   S
(106)-([\d][\d])(..)(\.).([A-Z]).
   1        2     3   4     5

1006  \3   \4   \5  \2
1006  OH   .    T   01
1006OH.T01.DTS



Here is your regex simplified, perhaps this help? Sorry, i didn't know your skill in regex :D
106-(\d\d)(..)\..(.)
1006\2.\3\1

CU
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions