|
From: Lenny G A. <ale...@ya...> - 2004-12-11 05:09:29
|
I could use some help expanding strings with text in
them.
Here's the problem:
UnicodeString input = "path1=C:\somedir\somefile,
path2=D:\temp";
UnicodeString matchpattern = "path.=(.*), path.=(.*)".
Iterating through the RegexMatcher::group()s gives the
expected:
m1 == "C:\somedir\somefile"
m2 == "D:\temp"
But now I want to use these UnicodeStrings as replace
strings in a new string, i.e., I want to call
RegexMatcher.replaceAll(m1,..) and replaceAll(m2,..),
searching through an input string like "p1=\1, p2=\2"
and making the substitutions.
Of course, since these strings are now interpreted as
patterns, '\s' and '\t' get turned into something
else. I've tried doing a replaceAll on them before
hand, turning all '\' into '\\', but I'm missing
something. How do I fix the following to do the right
thing?
RegexMatcher backslashMatcher("\\\\", 0, statcode);
backslashMatcher.reset(m1,statcode);
UnicodeString irep = backslashMatcher.replaceAll(
UNICODE_STRING_SIMPLE("\\\\\\"), statcode);
As is, this results in garbage like
"픈䀰temp" instead of the expected
"D:\\temp".
Any help would be appreciated!
Lenny G
BTW, the approach I described above is working for
strings that don't have '\'s in them.
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com
|