I tryed that, but I'm getting an error:
Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 26....Then it list the path of the file and points to one of the "\" charaters seperating the path.
Code:public void processFind() { String searchString = JOptionPane.showInputDialog("Enter the string to search for"); if (getFile == null) { String val = textArea2.getText(); int left = val.indexOf(searchString); int right = left + searchString.length(); textArea2.setSelectionStart(left); textArea2.setSelectionEnd(right); } else if (getFile != null) { Scanner s = new Scanner(getFile); Pattern p = Pattern.compile(getFile); String result = s.findInLine(p); textArea2.append(result); } else { } }




Reply With Quote