in reply to Passing a variable to a regex
Hello mavericknik,
I see choroba has answered your question, but I wanted to ask: what is [NOR|OR] supposed to do in the regex? It is actually a character class, which matches any one character from the list “N”, “O”, “R”, “|”:
21:10 >perl -wE "my $s = ' NOR42'; $s =~ / [NOR|OR](.*)/; say $1;" OR42 21:10 >
Did you mean to write this: (?:NOR|OR)? If so, it can be shortened to: N?OR.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Passing a variable to a regex
by mavericknik (Sexton) on Sep 17, 2015 at 11:37 UTC |