On Wed, 2004-10-27 at 20:07, S.A. Birl wrote:
> On Oct 27, [EMAIL PROTECTED] ([EMAIL PROTECTED]:
> 
> Brian:
> Brian:  If you want to make sure they are alternating like <><><> etc... I would do
> Brian:  this:
> Brian:
> Brian:  $_ = $line;
> Brian:
> Brian:  @syms = m/[<>]/g;
> Brian:  $string = join("", @syms);
> Brian:  if ($strings !~ m/^<(><)*>$/)
> Brian:  {
> Brian:        ## Scream here!
> Brian:  }
> Brian:
> Brian:  The regular expression:
> Brian:
> Brian:  m/^<(><)*>$/
> Brian:
> Brian:  will ensure that it starts with < and ends with > and anything in between
> Brian:  will be "><" which I think should do the trick. That logic is pretty hairy
> Brian:  though and I could be missing something.
> 
> 
> 
> Wouldnt m/[<>]/g literally match <> and not <characters>?
> 
> Why wouldnt it be m/[<.+>]/g ?

Brackets in a regular expression match a single character inside the
brackets.  It's the RE equivalent to an OR.  So m/[<>]/g will match each
instance of '<' or '>'.  The match will be a single character long.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to