[PJUG Javamail] Silly Regex Question
Richard Johnson
richardj at lingosys.com
Tue Jun 23 12:17:22 EDT 2009
Hi all,
What's wrong with my logic and/or regex?
I'm parsing a text file, extracting hopefully useful information from a
stated directory path. I have a java pattern/regex that looks like
this:
String[] languages = new String[2];
String[] foo = inputLine.split("\\\\");
Pattern langs = Pattern.compile("_TM");
int toggle = 0;
for(int i = 0; i < foo.length; i++) {
Matcher m = langs.matcher(foo[i]);
if(m.find() && toggle == 0) { //we have a language, but it's the
first one
toggle = 1;
languages[0] = fetchLanguageName(foo[i]);
}
else if(m.find() && toggle == 1) { //the second language we find
toggle = 2;
languages[1] = fetchLanguageName(foo[i]);
}
}
Given an input line like this:
Translation Memory:
X:\2Checkout\2Checkout_English(U.S.)_TM\2Checkout_Chinese(Traditional)_T
M\cht_2CheckOut.tmw
It quite happily finds the first occurrence of '_TM' but then fails to
trigger on the second. (i.e. we find English but not Chinese.)
--
Richard Johnson, Systems Architect
Lingo Systems
15115 SW Sequoia Pkwy #200
Portland Oregon 97224
richardj at lingosys.com
http://www.lingosys.com <http://www.lingosys.com/>
voice 503-419-4889 or 800-878-8523
FAX 503-419-4873
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pjug.org/pipermail/javamail/attachments/20090623/098960fe/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/bmp
Size: 50186 bytes
Desc: untitled.bmp
Url : http://www.pjug.org/pipermail/javamail/attachments/20090623/098960fe/attachment.bmp
More information about the Javamail
mailing list