java regex - matching part of string stored in variable -
i need extract directory file in, in folder path. so, created simple regex. here example path \\myvdi\prod\2014\10\ltcg\ltcg_v2306_03_07_2014_1226.pfd
the regex below find need, problem storing variable. have below. fails @ string array
string[] temp = targetfile.split("\\.*\\"); folder = temp[0];
suggestions?
thanks!
edit exception being thrown is: java.util.regex.patternsyntaxexception: unexpected internal error near index 4
simply, need:
string path = "\\myvdi\\prod\\2014\\10\\ltcg\\ltcg_v2306_03_07_2014_1226.pfd"; string dir = path.substring(0, path.lastindexof("\\") + 1);
Comments
Post a Comment