i have a .txt file, which looks like this(just example):
sfafsaf102030
asdasa203040
asdaffa304050
sadasd405060
I am trying to get whole line which contains a specific(given by me) number, for example i have number "203040" and i want to receive "asdasa203040".
I tried something like this:
File file = new File("file.txt");
Scanner sc = new Scanner(file);
String pattern = "(.*)(\\d+)";
Pattern p = Pattern.compile(pattern);
System.out.println(sc.findInLine(pattern));
but it only gives me line with any number and not the one i specified. How to change it?
Thanks.