Hi all,
I am searching for a way to find repetetive characters from a string and work with them. I have found something that works, but looking at it, it doesn't look like the right solution to me. I was hoping some of you know a better solution.
Here's my code:
my @numbers = $aKnosID =~ m/([a]{2,}|[b]{2,}|[c]{2,}|[d]{2,}|[e]{2
+,}|[f]{2,}|[g]{2,}|[h]{2,}|[i]{2,}|[j]{2,}|[k]{2,}|[l]{2,}|[m]{2,}|[n
+]{2,}|[o]{2,}|[p]{2,}|[q]{2,}|[r]{2,}|[s]{2,}|[t]{2,}|[u]{2,}|[v]{2,}
+|[w]{2,}|[x]{2,}|[y]{2,}|[z]{2,})/g;
if ( @numbers > 0 ) {
#repetetive strings here;
for ($i=0;$i<@numbers;$i++) {
#Do something
}
}
else {
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.