Check for yes and no

Tiny code snippit, you can use regex to check for any variation of Yes or No in java like this

“STRING”.matches(“[nN]|[nN][oO]”)

“STRING”.matches(“[yY]|[yY][eE][sS]”)

this finds “N”:”n”:”NO”:”No”:”no” etc etc etc

useful.

Leave a Reply

Your email address will not be published.