You're probably better off using good ole' substr instead. It's built for doing such things.
If you really want to use a regex for some perverse reason -- well, then you're stark raving mad. But in good company. Anyways, think on the following:
| English | Regex translation |
|---|---|
| We want to match.. | $callerid =~ / |
| ..and remember.. | ( |
| ..any character.. | . |
| ..7 times.. | {7} |
| ..stop remembering.. | ) |
| ..then the end of line.. | $ |
| ..and that's the end of the match. | /; |
Putting that all together, we would get $callerid =~ /(.{7})$/; which would leave the last seven digits in $1. I will reiterate that you don't want to do this, though. It's slow and ugly; use substr. The above was provided as a learning exercise.
Share and enjoy. :)
perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'
In reply to Re: PLEASE HELP!!! REGEXP
by Chmrr
in thread Get last 7 characters with regexp (was: PLEASE HELP!!! REGEXP)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |