Regex to find an alphanumeric sequence in a block of text.
-
I need to find an alphanumeric sequence example:1wer3rtyu4sd inside a block of text to which the alpanumeric sequence is unique. I am using the following piece of code: Pattern pattern = Pattern.compile(regex);//need a proper regex Matcher matcher = pattern.matcher(strLine); //strLine consists the text if (matcher.find()) { System.out.println(matcher.group()); System.out.println(matcher.groupCount()); }
-
I need to find an alphanumeric sequence example:1wer3rtyu4sd inside a block of text to which the alpanumeric sequence is unique. I am using the following piece of code: Pattern pattern = Pattern.compile(regex);//need a proper regex Matcher matcher = pattern.matcher(strLine); //strLine consists the text if (matcher.find()) { System.out.println(matcher.group()); System.out.println(matcher.groupCount()); }
Your question is unclear. Are you searching for a pattern that you already know exactly? If so, use strLine.indexOf(wantedString). If you are doing something selse, you need to tell us more about how to specify the search pattern. Peter
Software rusts. Simon Stephenson, ca 1994.