[buug] regex question
Nick Moffitt
nick at zork.net
Wed Apr 30 13:55:12 PDT 2003
begin johnd quotation:
> Can someone give me a regex to find some text?
>
>
> I have a file with lines like this
>
> aaaaaaaaaaaaUserID=123213&bbbbbbbbbbbbbbbbbbbbbbbbbb
>
>
> I need a regex to substitue on that gives me
>
> the part after the = and before the &
>
> in this case 123213
>
> it is not for sure the the string will be numeric or alpha
>
> I just know it is the text between UserID= and &
If you're using a system that allows you to save references,
such as sed, Perl, or awk, you can wrap your answer in parens
(appropriately backwhacked for your implementation).
For example:
$ echo 'aaaaaaaaaaaaUserID=123213&bbbbbbbbbbbbbbbbbbbbbbbbbb' | sed 's/^.*UserID=\([^&]\+\)\&.*$/\1/'
123213
Note that your backwhacks may vary, and Perl uses $1 instead of \1.
Apologies for the long line.
--
end
More information about the buug
mailing list