package com.acme.logs;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MatcherTest {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("ORA-[0-9]*");
Matcher matcher = pattern.matcher("ciao ORA-11234 pippo");
boolean found = false;
while (matcher.find()) {
System.out.println("I found the text " + matcher.group() + " starting at " +
"index " + matcher.start() + " and ending at index " +
matcher.end());
found = true;
}
if(!found){
System.out.println("No match found.%n");
}
}
}
I found the text ORA-11234 starting at index 5 and ending at index 14
No comments:
Post a Comment