sauloco sauloco - 1 month ago 4x
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

You can try with following regex:

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