I have created a program which gets the string from the putty and kills the processID from getting processID from that string. Currently it is working fine but sometimes it is not reliable.
Please find the target and the regex I used below.
Target String: root 14139 1 25 Aug03 ? 06:47:50 /usr/local
RegEx I used: \\\d{3,5}
I want to get the RegEx which can find the immediate number after root and ignore the other text. (e.g., I want to extract 14139 from the example string removing all the extra space.)
How can I do it?
s = s.replaceFirst("^.*\\broot\\s+(\\d{3,5}).*$", "$1");