gerry.odea
Posts: 98 Joined: Fri Sep 19, 2008 9:33 am
Post
by gerry.odea » Mon Feb 10, 2020 2:17 pm
<$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.
Kai
Site Admin
Posts: 1272 Joined: Tue Apr 25, 2000 1:27 pm
Post
by Kai » Mon Feb 10, 2020 2:45 pm
<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.
Kai
Site Admin
Posts: 1272 Joined: Tue Apr 25, 2000 1:27 pm
Post
by Kai » Mon Feb 10, 2020 2:48 pm
On second thought, a better version would be:
<rex ">>[?&]v\=\P=[^&;]*" $x>
which will ensure that it doesn't match on `xyz=...'.