Using split we use the capturing feature and grep out the extraneous data to get the desired output. With the regex we do something similar by capturing all the groups in the string. So it would seem, in this case the regex approach would be better.$_ = '12d.9j7h.7tttt.125.ty.2.4.8.9f.y6.34gk.ll'; print "split: ", map "[$_]", grep $_, split /((?:\w+.){3}\w+)\.?/; print "regex: ", map "[$_]", m< ( (?: \w+. ){3} \w+ ) \.? >xg; __output___ split: [12d.9j7h.7tttt.125][ty.2.4.8][9f.y6.34gk.ll] regex: [12d.9j7h.7tttt.125][ty.2.4.8][9f.y6.34gk.ll]
See. perlre and split for more info.
HTH
_________
broquaint
update: fixed code (wasn't dealing with the last group correctly)
In reply to Re: regex needed for dot delimited string
by broquaint
in thread regex needed for dot delimited string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |