first location

A swapping-ground for Regular Expression syntax

first location

Postby BRUphil » Mon Nov 07, 2005 6:33 am

somenamesxyzs.mp3
othersabc.mp3
I want to make it xyzssomenames.mp3

(.*s)(.*)\.

replace
\2\1
works on 1st one only and not second because of second s

abc01xyz.mp3
sdfkfj04Act4.mp3
(.*)(\d*.*)
\2\1

this makes sense to me but doesn't work
BRUphil
 
Posts: 7
Joined: Mon Nov 07, 2005 2:56 am

Re: first location

Postby Stefan » Mon Nov 07, 2005 6:54 pm

BRUphil wrote:somenamesxyzs.mp3
othersabc.mp3
I want to make it xyzssomenames.mp3

(.*s)(.*)\.

replace
\2\1
works on 1st one only and not second because of second s

abc01xyz.mp3
sdfkfj04Act4.mp3
(.*)(\d*.*)
\2\1

this makes sense to me but doesn't work


First: you didn't must include the extensions in your regex

Second: i think you mean "works on 2cd one only", isn't it?
'cus ".*s" means "Zero or more characters followed by an 's' "
so your regex match on the first 's' of "somenamesxyzs.mp3"

So better try an ".+s" ,,,, "One or more characters followed by an 's' "

But this works only in your example.
You have one times 4 chars (xyzs) and one times 3 chars (abc)
For an regex you need an fixed part
like separate allways the last 3 chars or the last 4 chars.
Or on an given char like '-' or '_' or ...


Here is also an overwiev about regex
http://www.bulkrenameutility.co.uk/Foru ... 4dc1296813
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby BRUphil » Tue Nov 08, 2005 1:28 am

thank you for reply
I made an arbitrary example but it was as I intended. my actual does not lead with 's'
You are right, I didn't notice the first s but that doesn't matter.

my question is how do I match the first section with an 's'
I can only get 2nd 's' never 1st 's'

xxxxxxxxxsyyyyyyyyskkkk
and
xxxszzzzzzskkkk

how to transpose to
yyyyyyyyskkkkxxxxxxxxxs
and
zzzzzzskkkkxxxs


Please note. some documents on regex say (m) matches m number of preceeding (non-greedy)

I don't know how to make that work.
(s)(.*) will start at first 's' but I can't get group before first 's'
(.*)(s)(.*) starts at 2nd s so I can't get group before first 's'
BRUphil
 
Posts: 7
Joined: Mon Nov 07, 2005 2:56 am

Postby BRUphil » Tue Nov 08, 2005 1:48 am

visualregx is big help
([^s]*)(.*) works

Thanks for help
BRUphil
 
Posts: 7
Joined: Mon Nov 07, 2005 2:56 am

You sure

Postby clock345 » Fri Nov 11, 2005 3:40 am

Are you sure about that because i dont think so.
clock345
 
Posts: 7
Joined: Sat Oct 08, 2005 11:37 am

Postby BRUphil » Fri Nov 11, 2005 6:50 am

that at least stopped at the first 's' so I knew my problem was all but solved
I just added another group and recombined on 3 groups
([^s]*)(s)(.*)
BRUphil
 
Posts: 7
Joined: Mon Nov 07, 2005 2:56 am


Return to Regular Expressions