JavaScript regular expression mobile phone number [duplicate]


This question already has an answer here:

<ul><li> <a href="/questions/123559/a-comprehensive-regex-for-phone-number-validation" dir="ltr" rel="nofollow">A comprehensive regex for phone number validation</a> <span class="question-originals-answer-count"> 39 answers </span> </li> </ul> <blockquote> <ol><li>XXX-XXX-XXXX</li> <li>XXXXXXXXXX</li> </ol>

I want to use a regular expression of the format. I tried as shown below, and an error occurs. How do I fix it?

</blockquote> <hr /><ol><li>sample var regExp = / ^ 01 ([0 | 1 | 6 | 7 | 8 | 9]?) - ([0-9] {3}) - ([0-9] {4}) $ /??;</li> <li>sample var regExp = / ^ 01 ([0 | 1 | 6 | 7 | 8 | 9]?) ([0-9] {3}) ([0-9] {4}) $ /??;</li> </ol>


sample 1

var regExp = /^01([016789]?)-([0-9]{3})-([0-9]{4})$/;

sample 2

var regExp = /^01([016789]?)[0-9]{3}[0-9]{4}$/;

just make sure you don't have spaces and remove | from [0|1|6|7|8|9]


  • Stacked barplot using R base: how to add values inside each stacked bar
  • how to store images in sql server? [duplicate]
  • gcloud compute on hadoop cluster has insufficient permission
  • Lowercase part of a string with XPath regular expression
  • Google custom search API with pagination
  • GCM push notification with C# asp.net giving null as notification in android devices
  • How to add a custom HTTP header to ajax request with js or jQuery
  • Active Directory Powershell - forest-wide search script using .csv list of users
  • PHP exec response as string?
  • Creating Setup of large data with NSIS Script
  • How to include Web reference endpoint configuration in another project
  • Exporting SAS DataSet on to UNIX as a text file…with delimiter '~|~'
  • php notice undefined index http_host in $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'
  • Fraction length
  • My first C# WPF ValidationRule is not firing
  • Raphael.js function getBBox give back NAN/NAN/NAN in IE8
  • matching similar elements in between two lists
  • How to convert integer to string and get length of string
  • Bad interaction between Zope2 XML-RPC and AT Image mutator?
  • jquery validation - waiting for remote check to complete
  • IE10 strips out hashtag from the URL
  • Create a link to a web page that runs a Javascript function on the page
  • Blackberry 6: how to detect a long click on track pad?
  • How to pass nginx proxy url for socket
  • how to set variables in a php include file?
  • Login not working in Firefox in Meteor
  • Transactional Create with Validation in ServiceStack Redis Client
  • How to define and use opencv mat of user type
  • Content-Length header not returned from Pylons response
  • Extracting HTML between tags
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • MySQL WHERE-condition in procedure ignored
  • vba code to select only visible cells in specific column except heading
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Do I've to free mysql result after storing it?
  • Jquery - Jquery Wysiwyg return html as a string
  • Arrays break string types in Julia
  • WPF Applying a trigger on binding failure
  • Java static initializers and reflection