New radio PIDs
Ralph Corderoy
ralph at inputplus.co.uk
Sun Aug 13 02:05:39 PDT 2017
Hi Vangelis,
> ...to begin with either "b0" or "p0".
>
> New radio PIDs like "w3csv1y9" or "w3csvnyc", beginning with "w3",
...
> [bp]0[a-z0-9]{6}
> with
> [bpw][a-z0-9]{7}
Other approaches, getting gradually more specific.
^[bpw][03][a-z0-9]{6}$
But this allows b3.
^(b0|p0|w3)[a-z0-9]{6}$
This is precise, but it's common to factor out alternations since
each is tried in turn, so...
^([bp]0|w3)[a-z0-9]{6}$
This is as precise.
The remaining problem is the `()' "capture" what matches for retrieval
by the program afterwards as $1, $2, ... By introducing another set of
`()' we'd have affected the position of any that come afterwards in the
same regexp. (None in this case.) It's also inefficient to capture
when it's unnecessary. `()' can be marked as non-capturing with `?:'.
^(?:[bp]0|w3)[a-z0-9]{6}$
These regexps aren't specific to Perl, BTW, but are useful with egrep,
awk, Python, etc.
--
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy
More information about the get_iplayer
mailing list