regex problem - allowing optional space
Hi,
I'm trying to get an expression to match a string with an option space in the second position. I've tried the following patterns with no luck. The pattern is to not match "<bP>" where b is an optional space. I've tried \\s for white space, [ ] with space between, no luck.
Quote:
System.out.println("< P> <B>and <P>".replaceAll("< *?[^P].*?>", "")); // and <P>
System.out.println("<P> <B>and <P>".replaceAll("< *?[^P].*?>", "")); // <P> and <P>
The string in the first has a space between the < and the P.
Desired result for first string: < P> and <P>
Thanks,
Norm