ivbtar ivbtar - 27 days ago 15
Java Question

Matching exclamation mark in a string in java

I have a line " !".
White space and !.
Two character string.
How can i match this line with java pattern match.
I tried

"^\\s{1}[^\\s]+!"


but not working.

Answer

Use the following pattern.

^\s!