Alex Rivera | Logout

Regular expressions to match n digit number

Asked 2011-11-03T17:27:18.750
23

Could someone tell me what the regular expression would be to match: number with n digits where n would be provided or ( or )

Edit
Report

1 Answer

1

I believe this will work for you. It matches strings with n numbers or strings like "(" or ")". Exmpl.: for n = 2 it matches strings like "12", "22" ....

^([0-9]{n})$|^([()]{1})$
answered 2011-11-03T17:39:32.460

Your Answer