I have such a directory and I am trying to extract the word "photon" immediately before "photon.exe".
C: \ workspace \ photon \ output \ i686 \ diagnostic \ photon.exe (suspended) Subject (work)
My code is as follows:
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));
No matter what permutations I try, I keep getting IllegalStateExceptions, etc., despite this regex working on http://www.regexplanet.com/simple/index.html .
Thanks in advance for any help. At this moment, I am very upset>. <
source
share