<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18783"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=298073916-23062009><FONT color=#0000ff 
size=2 face=Arial>Doh!&nbsp; </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=298073916-23062009><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=298073916-23062009><FONT color=#0000ff 
size=2 face=Arial>Thanks, Zack.&nbsp; :-)</FONT></SPAN></DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> Zack Radick [mailto:zack@crc-corp.com] 
<BR><B>Sent:</B> Tuesday, June 23, 2009 9:36 AM<BR><B>To:</B> Richard Johnson; 
javamail@pjug.org<BR><B>Subject:</B> Re: [PJUG Javamail] Silly Regex 
Question<BR></FONT><BR></DIV>
<DIV></DIV>Richard,<BR><BR>Since you are not matching an expression per se, I 
would recommend the following for simplicity (as it seems to be what you are 
looking for):<BR>foo[i].contains( "_TM" )<BR><BR>You could also do the following 
if it was more in line with your needs:<BR>foo[i].endsWith( "_TM" 
)<BR><BR>--Zack<BR><BR>At 09:17 AM 6/23/2009, Richard Johnson wrote:<BR>
<BLOCKQUOTE class=cite cite="" type="cite">Content-class: 
  urn:content-classes:message<BR>Content-Type: 
  multipart/related;<BR><X-TAB>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</X-TAB> 
  boundary="----_=_NextPart_001_01C9F41E.16A2CB20";<BR><X-TAB>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</X-TAB> 
  type="multipart/alternative"<BR><BR><FONT size=2>Hi 
  all,<BR></FONT>&nbsp;<BR><FONT size=2>What's wrong with my logic and/or 
  regex?<BR></FONT>&nbsp;<BR>&nbsp;<BR><FONT size=2>I'm parsing a text file, 
  extracting hopefully useful information from a stated directory path.&nbsp; I 
  have a java pattern/regex that looks like this:<BR></FONT>&nbsp;<BR><FONT 
  size=2>String[] languages = new String[2];<BR>String[] foo = 
  inputLine.split("<A href="??">\\\\</A>");<BR>&nbsp;&nbsp;&nbsp; Pattern langs 
  = Pattern.compile("_TM");<BR>&nbsp;&nbsp;&nbsp; int toggle = 
  0;<BR>&nbsp;&nbsp;&nbsp; for(int i = 0; i &lt; foo.length; i++)&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp; Matcher m = 
  langs.matcher(foo[i]);<BR>&nbsp;&nbsp;&nbsp; if(m.find() &amp;&amp; toggle == 
  0) {&nbsp; //we have a language, but it's the first 
  one<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toggle = 
  1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; languages[0] = 
  fetchLanguageName(foo[i]);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else 
  if(m.find() &amp;&amp; toggle == 1)&nbsp; {&nbsp; //the second language we 
  find<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; toggle = 
  2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; languages[1] = 
  fetchLanguageName(foo[i]);<BR>&nbsp;&nbsp;&nbsp; }<BR>}<BR>Given an input line 
  like this:<BR>&nbsp;&nbsp;&nbsp; Translation Memory: 
  X:\2Checkout\2Checkout_English(U.S.)_TM\2Checkout_Chinese(Traditional)_TM\cht_2CheckOut.tmw<BR></FONT>&nbsp;<BR><FONT 
  size=2>It quite happily finds the first occurrence of '_TM' but then fails to 
  trigger on the second.&nbsp; (i.e. we find English but not Chinese.)&nbsp; 
  <BR></FONT><BR>-- <BR><BR>Richard Johnson, Systems Architect&lt;?xml:namespace 
  prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;<BR><BR>Lingo 
  Systems<BR><BR>&lt;?xml:namespace prefix = st1 ns = 
  "urn:schemas-microsoft-com:office:smarttags" /&gt;15115 SW Sequoia Pkwy 
  #200<BR><BR>Portland Oregon 97224<BR><BR><A 
  href="mailto:richardj@lingosys.com">richardj@lingosys.com</A><BR><BR><A 
  href="http://www.lingosys.com/" 
  eudora="autourl">http://www.lingosys.com</A><BR><BR>voice&nbsp; 503-419-4889 
  or 800-878-8523<BR><BR>FAX&nbsp;&nbsp; 503-419-4873<BR><BR>&nbsp;<BR><BR><IMG 
  alt=[] src="cid:298073916@23062009-2FFF" width=201 height=83> 
  <BR>&nbsp;<BR><BR><BR>_______________________________________________<BR>Web 
  Site - <A href="http://www.pjug.org/" 
  eudora="autourl">http://www.pjug.org/</A> <BR>Javamail mailing 
  list<BR>Javamail@pjug.org<BR><A 
  href="http://www.pjug.org/mailman/listinfo/javamail" 
  eudora="autourl">http://www.pjug.org/mailman/listinfo/javamail</A></BLOCKQUOTE></BODY></HTML>