With the following regular expression (^ DOC) * [0-9] I can capture all the numbers after the "DOC" sequence. However, by testing in this text:
TEXT TEXT TEXT TEXT DOCUMENT: 240010 9/24/2014
It returns me "24001024092014", the date comes along. The question is, how do I get the number sequence, and if I find a space, it does not include in the regex? I would like to capture only the document number.
Follow the java code:
public class Teste {
public static void main(String args[]){
String CAPTURAR_SOMENTE_NUMEROS_APOS_PALAVRA_DOC = "(^DOC)*\d+ ";
Pattern pattern = Pattern.compile(CAPTURAR_SOMENTE_NUMEROS_APOS_PALAVRA_DOC);
Matcher matcher = pattern.matcher("TEXTO TEXTO TEXTO TEXTO DOCUMENTOLEGAL:240010 24/09/2014 ");
while(matcher.find()){
System.out.printf(matcher.group());
}
}
}