in reply to use of 'or' in regex
In this case, perl will return the list of those patterns that match. So you're ok, since your patterns don't overlap.
If you had something like this:
then the DPLA alternative would never match, since DPL would.$str=~/(DPL|DPLA)/g
Edit: Someone said in /msg that I'm wrong if the string is "DPLA DPL", claiming both will match.
However, in that case, _DPL_ is what matches twice; DPLA never matches.
If I had specified DPLA|DPL, then the match would have been as expected.$ perl -ne'while(/(DPL|DPLA)/g){print " > $1 <\n"}' DPL > DPL < DPLA > DPL < DPLA DPL > DPL < > DPL < DPLA DPLA > DPL < > DPL <
|
|---|