sauloco sauloco - 3 months ago 6
Java Question

Pattern in regexp

I have a pattern like:

string [number|number]


I want validate with RegExp in Java.

Case valid:
"blablabla blabla blabla [12|1234]"


Any other would be invalid.

I don't realise how to do it.

hsz hsz
Answer

You can try with following regex:

^[a-zA-Z ]+\[\d+\|\d+\]$