I need a regular expression for my yupp / formik validation for a react app. The requirement is that the pattern should match with numbers starting or 91 or 971 and can have up to 14 characters(includes digits or in the beginning) in total. A regex with a brief explanation would be helpful.
CodePudding user response:
This regex pattern which match your described formats.I have allowed for between 12 and 14 digits, interspersed with hyphens or spaces.
((\ 91|91[ -]?\d|971)([ -]?\d){9,11})((?!\D).)?