/* package whatever; // don't place package name! */
/*
Java pattern to match ; while skipping it in &
Desired output:
Match found
there was a rat & a cat
they lived happily together.
*/
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class PatternTest{
public static void main
(String args
[]){ String line
= "there was a rat & a cat; they lived happily together."; Pattern r = Pattern.compile("(?<!&[a-z]{1,4});");
Matcher m = r.matcher(line);
if (m.find())
System.
out.
println("Match found"); else
System.
out.
println("No Match found");
String[] sa
= line.
split("(?<!&);"); }
}