我有一个这样的目录,我试图从"photon.exe"之前提取"光子"一词.
C:\ workspace\photon\output\i686\diagnostic\photon.exe(Suspended)线程(正在运行)
我的代码看起来像这样:
String path = "C:\workspace\photon\output\i686\diagnostic\photon.exe(Suspended) Thread(Running)";
Pattern pattern = Pattern.compile(".+\\\\(.+).exe");
Matcher matcher = pattern.matcher(path);
System.out.println(matcher.group(1));
Run Code Online (Sandbox Code Playgroud)
无论我尝试什么样的排列,我都会继续获取IllegalStateExceptions等,尽管这个正则表达式在http://www.regexplanet.com/simple/index.html上运行.
在此先感谢您的帮助.我在这一点上非常沮丧>.<