perl -MData::Dumper -le &#39;$a=&quot;15678.91 ml; r45.12 &quot;; @a=grep !/^\s*$/, split /([\d\.]+)/, $a; print Dumper  \@a&#39; <br><br>the regex pattern for split don&#39;t need to be that complicated. :-)<br><br><br><br>
<div class="gmail_quote">2009/10/23 tiger peng <span dir="ltr">&lt;<a href="mailto:tigerpeng2001@yahoo.com">tigerpeng2001@yahoo.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: Courier New,courier,monaco,monospace,sans-serif; font-size: 10pt;"><div><font face="arial, helvetica, sans-serif">Hello everyone,</font></div>
<div><font face="arial, helvetica, sans-serif"></font> </div>
<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="arial, helvetica, sans-serif">I am trying to isolate numbers from string, manipulate the numbers then put them back to original positions in the string. When I try to use zero-width separator, the split function looks weird, it generated much more elements than I expect.</font></span></div>

<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="arial, helvetica, sans-serif"></font></span> </div>
<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="arial, helvetica, sans-serif">Are there any mistakes? Why the split behaviors like this? (The regexp looks right when I used it s///)</font></span></div>

<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="Arial"></font></span> </div>
<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="Arial">Could anyone help?</font></span></div>
<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="Arial"></font></span> </div>
<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="Arial">Thanks,</font></span></div>
<div><span style="font-family: &#39;Courier New&#39;; color: black; font-size: 10pt;"><font face="Arial">Tiger</font></span></div>
<div> </div>
<div>#build the seperator</div>
<div>:-) perl -le &#39;$a = &quot;15678.91 ml; r45.12 &quot;;</div>
<div>              $a =~ s/((?!(\d|\.))(?&lt;=(\d|\.)))|((?=(\d|\.))(?&lt;!(\d|\.)))/|/g;</div>
<div>              print $a&#39;<br>|15678.91| ml; r|45.12|</div>
<div> </div>
<div>#use the seperator in split</div>
<div>:-) perl -MData::Dumper -le &#39;$a = &quot;15678.91 ml; r45.12 &quot;;</div>
<div>                             @a = split /((?!(\d|\.))(?&lt;=(\d|\.)))|((?=(\d|\.))(?&lt;!(\d|\.)))/, $a;</div>
<div>                             print Dumper(@a)&#39;<br>$VAR1 = &#39;15678.91&#39;;<br>$VAR2 = &#39;&#39;;<br>$VAR3 = undef;<br>$VAR4 = &#39;1&#39;;<br>$VAR5 = undef;<br>$VAR6 = undef;<br>$VAR7 = undef;<br>$VAR8 = &#39; ml; r&#39;;<br>
$VAR9 = undef;<br>$VAR10 = undef;<br>$VAR11 = undef;<br>$VAR12 = &#39;&#39;;<br>$VAR13 = &#39;4&#39;;<br>$VAR14 = undef;<br>$VAR15 = &#39;45.12&#39;;<br>$VAR16 = &#39;&#39;;<br>$VAR17 = undef;<br>$VAR18 = &#39;2&#39;;<br>
$VAR19 = undef;<br>$VAR20 = undef;<br>$VAR21 = undef;<br>$VAR22 = &#39; &#39;;<br></div></div></div><br>_______________________________________________<br>
China-pm mailing list<br>
<a href="mailto:China-pm@pm.org">China-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/china-pm" target="_blank">http://mail.pm.org/mailman/listinfo/china-pm</a><br></blockquote></div><br>