[Solved] Regular expression for phone numbers in c


Check whether this works or not. I assume that you are using Extended Regular Expression (REG_EXTENDED flag):

"^(?\\([0-9]{3}\\))?[-. ]?\\([0-9]{3}\\)[-. ]?\\([0-9]{4}\\)$"

ERE is a bit different in the fact that it treats (, ) as literal (, ) and \(, \) as grouping.

References:

2

solved Regular expression for phone numbers in c