Page 1 of 1

REX Question

Posted: Mon Feb 10, 2020 2:17 pm
by gerry.odea
<$ShowURL=www.youtube.com/watch?v=mj9ncegifsa>

I want to do a rex to just pull out "mj9ncegifsa" from the v=
everytime

How would I write it? Thanks in advance.

REX Question

Posted: Mon Feb 10, 2020 2:45 pm
by Kai
<rex ">>v\=\P=[^&;]*" $ShowURL>

would work. That will also skip any following query-string variables; e.g. for `www.youtube.com/watch?v=mj9ncegifsa&foo=bar' it would still pull out just the `v' value.

It works by looking for `v=' first (the `>>' anchor says start here first), then ignores that (the `\F'), then grabs all chars after that up until the next ampersand, semicolon, or end of string.

REX Question

Posted: Mon Feb 10, 2020 2:48 pm
by Kai
On second thought, a better version would be:

<rex ">>[?&]v\=\P=[^&;]*" $x>

which will ensure that it doesn't match on `xyz=...'.