Wednesday, 18 September 2013

Pattern Matching for java using regex

Pattern Matching for java using regex

I have a Long string that I have to parse for different keywords. For
example, I have the String:
"==References== This is a reference ==Further reading== *{{cite
book|editor1-last=Lukes|editor1-first=Steven|editor2-last=Carrithers|}} *
==External links=="
And my keywords are
'==References==' '==External links==' '==Further reading=='
I have tried a lot of combination of regex but i am not able to recover
all the strings.
the code i have tried:
Pattern pattern = Pattern.compile("\\=+[A-Za-z]\\=+");
Matcher matcher = pattern.matcher(textBuffer.toString());
while (matcher.find()) {
System.out.println(matcher.group(0));
}

No comments:

Post a Comment