<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY 
style="WORD-WRAP: break-word; khtml-nbsp-mode: space; khtml-line-break: after-white-space">
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2>Martin,</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2>How 
about this:</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># this 
example contains numbers, whitespace and other irrelevant stuff, possibly 
newlines</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2>my 
$rain =&nbsp;"&nbsp;&nbsp; 345678&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
xxx\nblah";&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN><SPAN class=534403604-16042007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2>#magic:</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2>$rain 
=~ s/^.*?(\d+).*$/$1/s;&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># my 
explanation: </FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># the 
basic substitution operator looks like this: s///; but with extra characters 
between the slashes as required below....</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># ^.*? 
means match anything, starting from the start of the string (non-greedy, so it 
doesn't ever match a number)</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># 
(\d+) means match any continual section of numbers, and the&nbsp;brackets means 
remember them as $1</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># .*$ 
means match anything, finishing at the end string</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># the 
$1 means "replace the entire matched string with just the bit remembered in $1" 
(ie the numbers).</FONT></SPAN></DIV></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2># the 
's' at the end means don't treat newlines as special ( <A 
href="http://perldoc.perl.org/perlre.html">http://perldoc.perl.org/perlre.html</A>&nbsp;)</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2>#NOTE: 
this code gives you left-most string of consecutive numbers in any string.&nbsp; 
eg if $rain started as 'xxx1234yyy5678' it would end up as just 
'1234'</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN><SPAN class=534403604-16042007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff size=2>print 
$rain;&nbsp; # prints the string '345678'</FONT></SPAN></DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=534403604-16042007><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE>
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  brisbane-pm-bounces+david.bussenschutt=qmtechnologies.com@pm.org 
  [mailto:brisbane-pm-bounces+david.bussenschutt=qmtechnologies.com@pm.org]<B>On 
  Behalf Of </B>Martin Jacobs<BR><B>Sent:</B> Monday, 16 April 2007 2:34 
  PM<BR><B>To:</B> Brisbane Perl Group<BR><B>Subject:</B> [Brisbane-pm] Still 
  Struggling With Regex Syntax<BR><BR></FONT></DIV>
  <DIV>Hi folks,</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>I still don't get it (quite).</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>The story so far...</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>I&nbsp;have split my rainfall record, and the right-most scalar is 
  $rain.</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>I now want to make sure that $rain holds a numeric value, without any 
  whitespace, newlines or other nasties.</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>If I try</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV><FONT class=Apple-style-span face="Courier New">$rain = ($rain =~ 
  m|\d+\.?\d*|);</FONT></DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>It returns 1, which, presumably, is the number of times it gets a 
  match.</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV>
  <DIV>What's the right syntax for saying 'make $rain contain the numeric values 
  in $rain"?</DIV>
  <DIV><BR class=khtml-block-placeholder></DIV><BR>
  <DIV><SPAN class=Apple-style-span 
  style="WORD-SPACING: 0px; FONT: 12px Lucida Grande; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; khtml-text-decorations-in-effect: none; apple-text-size-adjust: auto; orphans: 2; widows: 2"><SPAN 
  class=Apple-style-span 
  style="WORD-SPACING: 0px; FONT: 12px Lucida Grande; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; khtml-text-decorations-in-effect: none; apple-text-size-adjust: auto; orphans: 2; widows: 2"><SPAN 
  class=Apple-style-span 
  style="WORD-SPACING: 0px; FONT: 12px Lucida Grande; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; khtml-text-decorations-in-effect: none; apple-text-size-adjust: auto; orphans: 2; widows: 2">
  <DIV>Regards,</DIV>
  <DIV>Martin</DIV>
  <DIV>Visit my website...</DIV>
  <DIV><A href="http://web.mac.com/martin_jacobs1"><SPAN class=Apple-style-span 
  style="COLOR: rgb(0,0,238); khtml-text-decorations-in-effect: underline">http://web.mac.com/martin_jacobs1&nbsp;</SPAN></A></DIV><BR 
  class=Apple-interchange-newline></SPAN></SPAN></SPAN></DIV><BR></BLOCKQUOTE>
<DIV><P><HR>
The message and any attachment is confidential and may be privileged or otherwise protected from disclosure. If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone.
</P></DIV>
</BODY></HTML>