in reply to Re: regex issue
in thread regex issue

Doesn't the regex substitution pattern have two parts...the part to be look for and the part to use for the replacement?

I like your solution, but I'm confused by the use of braces (i.e., { and }) for the first part and then it appears you're using the slash, /, for the second part.

Did you mean:

s{(\Qhttp://v2vi.click4assistance.co.uk/c4a.aspx?AccNo=Inter12109&IDENT=\E)US}${1}US}/g

If so, then how can you use the braces to separate the part of the substitution and also for the numeric placeholder? It seems like it should be something like this:

s|(\Qhttp://v3vi.click4assistance.co.uk/c4a.aspx?AccNo=Inter12109& +IDENT=\E)US|${1}UK|g;

so that the regex separators are distinct from the characters (like the braces) and don't get confused with the separators.

But you're a lot more experienced than I, so I'm sure I'm missing something...something that's probably obvious. As I noted, I really like your regex...even though I don't entirely understand it...so I'm anxious to learn more.

Thanks, JavaFan, I always learn from eveyone here.

ack Albuquerque, NM

Replies are listed 'Best First'.
Re^3: regex issue
by JavaFan (Canon) on Dec 12, 2009 at 11:44 UTC
    Yes, I should have used {} all the way:
    s{(\Qhttp://v2vi.click4assistance.co.uk/c4a.aspx?AccNo=Inter12109& +IDENT=\E)US}{${1}UK}g
    Note that both the pattern and the replacement have their own set of parens. You may write:
    s{(\Qhttp://v2vi.click4assistance.co.uk/c4a.aspx?AccNo=Inter12109& +IDENT=\E)US} {${1}UK}g
    as well.