Hi, I was wondering if anyone could help me with a problem I'm having in Java regarding Regex. All I'm trying to do (this is being dumbed down a bit) is scan a file, for specific text, and print it out. I'm trying to use regular expressions, but for some reason it isn't working the way it should.
[B]String regex = "(\\d+)";
Pattern regexpat = Pattern.compile(regex);[/B]
while (oneWord.hasMoreTokens()) {
Matcher numFind = regexpat.matcher((CharSequence) oneWord.toString());
boolean matchFind = numFind.find();
if (matchFind = true) {
System.out.println(oneWord.nextToken());
}
}
For testing sake, I'm using a really simple regular expression, but when I run the program, it prints out every single word in the text file. Does anyone know if I'm doing something wrong?