#. check the number of characters before the first "_" (underscore). #. If it's return only two characters, then get the string untill it reach the second "_"(underscore)Okay, well because you are looking for anything that is not an underscore, then a negated character class is probably the way to go. Something like this:
if (/^([^_]{2}_[^_]+)_/) { print $1; }
else if more than 2 characters then it must be a targetted patternSorry, but I don't get that. What is a "targetted pattern"?
I guess i can't able to use the "\w" (word) pattern, because it will take the whole string as a word.Yes and no. It's okay, because you are limiting it to only the first two characters with {2}. But it's probably not okay because \w will also match an underscore. So \w{2} would match something like "_a", which I'm pretty sure you don't want.
Cheers,
Darren :)
In reply to Re^3: Regular Expression - pattern matching
by McDarren
in thread Regular Expression - pattern matching
by kulls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |