[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

RE: XPL questions (Wildcards)



-----Original Message----- From: Harry Binswanger

> Find: {CR}http://{W}{W}{W}{W}{CR}
> Repl: {CR}≪LBhttp://{W}{W}{W}{W}{CR}

> Of course, the simple workaround is to use a loop to search for each URL
> and then put in the "≪LB" and then the closing "≫"--but that's so inelegant.

Harry, pretty much my entire history using Xy has been using it to do exactly what you're talking
about...changing text files from one state to another; from no markup, to having markup - from one
kind of markup, to another kind of markup - or just cleaning-up bad markup. If there's one primary
rule I have about writing scripts to do this sort of thing it's NEVER use a "wild string"
in a CI without lots of "concrete" text on either side.

In your example above, the left side of the WS is fine...a CR and the "http:// is plenty
"concrete". But having ONLY a CR after the last WS is asking for trouble. Your CI
(sometimes) will "find" more than you want it to. I have many times seen the first (or
more) CR ignored and the "end" of the string ends up being miles past where I intended. If
you're using it to Define, and you're lucky, you'll run out of memory before it gets to where it
thinks the end of the string is. At least then you'll have a quick indication of a problem.
Otherwise it might take awhile to figure out you have quite a mess (and a lot less file) on your
hands. I often don't find enough consistent text on both sides of a WS to ensure that it will
accurately find exactly what I want it to.

For my money, the "inelegant" way is the only safe way. For your example, I would find the
http://, back the cursor up 7 times, place the bracket, search for the next CR (if the URL is ALWAYS
ended that way), back-up 1 space and place the other bracket. I know it's "ugly" and more
work, but it wouldn't even occur to me, these days, to do that type of transform any other way.

-BrianH.