<!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.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Cody,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This is not entirely correct...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>$string =~ 
s\(<b>|</b>)\\;</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In this situation, /(string1|string2)/ 
perl looks for a match of either occurence of "string1" and "string2" per 
line. If "string1" is found, then perl will never search for "string2" on 
the same line. So when you run it only the first <b> tag will be removed 
and never the second</b>. In order to fix it a "g" would need to be added 
to the last "\" to tell perl not to stop searching after the first match is 
found. So...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>$string =~ 
s\(<b>|</b>)\\g;</STRONG></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>would work. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>However, alternation in regex is resource expensive 
and should be avoided if at all possible in complex 
operations.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><STRONG>man perlre</STRONG> is great for a quick 
reference ;)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>--Brian</FONT></DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=Cody.Taylor@hickam.af.mil 
  href="mailto:Cody.Taylor@hickam.af.mil">Taylor Cody L. Contr 502 AOS/PETS</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=luau@videl.ics.hawaii.edu 
  href="mailto:luau@videl.ics.hawaii.edu">luau@videl.ics.hawaii.edu</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, March 25, 2004 8:14 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [luau] Perl String 
  Question</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN class=603121018-25032004>It 
  looks like you already have your answer but since my friend replied I figured 
  I would forward it on.  -Cody</SPAN></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2><SPAN 
  class=603121018-25032004></SPAN></FONT> </DIV>
  <DIV><FONT face=Arial color=#0000ff size=2>-----Original 
  Message-----</FONT></DIV>
  <DIV><FONT face=Arial><FONT size=2><FONT color=#0000ff>From: Paul</FONT> 
  </FONT></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
  <DIV><FONT face=Arial color=#0000ff size=2>$string =~ 
  s\(<b>|</b>)\\;</FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
  <DIV><FONT face=Arial color=#0000ff size=2>FYI -</FONT></DIV>
  <DIV><FONT face=Arial><FONT size=2><FONT color=#0000ff>Normally those 
  backslashes would be forward slashes, but since his</FONT> 
</FONT></FONT></DIV>
  <DIV><FONT face=Arial><FONT size=2><FONT color=#0000ff>search string contains 
  forward slashes, you can use another symbol to</FONT> </FONT></FONT></DIV>
  <DIV><FONT face=Arial><FONT size=2><FONT color=#0000ff>keep perl from getting 
  confused. For instance, I could have wrote</FONT> </FONT></FONT></DIV>
  <DIV><FONT face=Arial color=#0000ff size=2>s*(<b>|</b>)** instead 
  and it would have meant the same thing.</FONT></DIV>
  <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
    <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
    size=2>-----Original Message-----<BR><B>From:</B> Matthew John Darnell 
    [mailto:mdarnell@servpac.com]<BR><B>Sent:</B> Wednesday, March 24, 2004 5:48 
    PM<BR><B>To:</B> luau@videl.ics.hawaii.edu<BR><B>Subject:</B> [luau] Perl 
    String Question<BR><BR></FONT></DIV>
    <DIV><FONT face=Arial size=2>Aloha,</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2>If I have a string "<b>Yo ho ho and a 
    bottle of rum</b>" is there an elegant way to eliminate the 
    '<b>' & '</b>'?</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2>It would also need to return 
    nothing for the string "<b></b>"</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2>I could hack something up, but I am 
    thinking it could be accomplished in one line of code.  I am sure there 
    is more than one way to do it.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2>As you probably guessed, I am parsing a web 
    page.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2>-Matt</FONT></DIV></BLOCKQUOTE>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>LUAU mailing 
  list<BR>LUAU@lists.hosef.org<BR>http://lists.hosef.org/cgi-bin/mailman/listinfo/luau<BR></BLOCKQUOTE></BODY></HTML>