REGEX : detecting repetitive caracters
Hi all,
I need to detect, in Perl, a [0-9a-zA-Z_] where first repetetive characters will be find. Ex : abcd => NOK aabcd => OK (aa) abcdyyyyyy => OK (yyyyyy thank you, Regards, |
Like you said, you need this.
So what effort have you made ?. |
Quote:
Daniel B. Martin . |
you ought to check how regexp groups work and how can you specify repetition of a group.
|
Back-reference is the right term here. Repetition is misleading.
A repetition of the previous search pattern character: Code:
[0-9a-zA-Z_]{2} Code:
([0-9a-zA-Z_])\1 Code:
perl -lne '/([0-9a-zA-Z_])\1/ and print $1' |
obviously, repetition was not used as a keyword, but was originally used by the OP (and was repeated). And also I did not want to give a full solution - because it is against the rules of LQ.
|
All times are GMT -5. The time now is 10:58 AM. |