[ale] sed & regex
Pete Hardie
pete.hardie at sciatl.com
Tue Mar 30 09:51:06 EST 2004
Keith Hopkins wrote:
> Hi folks,
>
> I hope someone can point me to the error of my ways....too difficult? Ok, how about a hand at a regex problem?
>
> I have some xml files I'm trying to convert for local browsing. "wget -m -k" almost does the trick, but the remaining files have this snippet left in them...
>
> "handbook.xml?part" as part of an href. The actual files have "?" in their names. If I convert the href from "?" to "%3F" then my browser is all happy and finds the files (otherwise, it prints nasty errors).
>
> The question is, how to replace all the "?" with "%3F". I tried `sed` since that seemed to be the natural solution, but it isn't working like I expected.
>
> I do this...
>
> sed "s/handbook.xml\?/handbook.xml\%3F/" handbook.xml > handbook.html
>
> and sed really converts the string to "handbook.xml??"
>
> Where is the extra "?" coming from??
>
> Alternately, I tried
> sed "s/handbook.xml\?part/handbook.xml\%3Fpart/" handbook.xml > handbook.html
> and that seems to work OK (for those lines that actually have "part" in them).
>
I tried
sed -e 's/\?/\%3F/' xxx > xxx.out, where xxx contained handbook.xml?part,
and got xxx.out containing handbook.xml%3Fpart. Perhaps you are using " instead
of ' around the sed parrtern and a shell expansion is biting you?
--
Pete Hardie | Goalie, DVSG Dart Team
posting from, but not |
speaking for: |
Scientific Atlanta, Digital Video Services Group
- - - - - - - Appended by Scientific-Atlanta, Inc. - - - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.
More information about the Ale
mailing list