www.webdeveloper.com
Results 1 to 4 of 4

Thread: help to write regular expression for Canadian Quebec vehicle number

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    3

    help to write regular expression for Canadian Quebec vehicle number

    Hi. Please help me to write a single expression to validate Canadian Quebec vehicle number
    I have for each example one expression but i cant combine it. Can you help me? Thanks!



    /^ [A-Z][0-9]{2}[\s][A-Z]{3}$/g; /*for A00 ABC*/
    /^ [0-9]{3}[\s][A-Z]{3}$/g; /*for 000 ABC*/
    /^ [A-Z]{3}[\s][0-9]{3}$/g; /*for ABC 000*/
    /^ [0-9]{3}[A-Z][0-9]{3}$/g; /*for 000H000*/


    Letters A, B, C, H may be replaced by other letters of the alphabet.

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,264
    A test (to make) with a combination of the first two and a simple or | between others.
    Code:
    var rgx = /^(([A-Z]|[0-9])[0-9]{2}[\s][A-Z]{3}|[A-Z]{3}[\s][0-9]{3}|[0-9]{3}[A-Z][0-9]{3})$/
    There is no need of g to validate a Canadian vehicle number with something like this
    Code:
    if (!rgx.test(vehicleNumber)) {alert('the vehicle number seems erroneous !');return}
    Last edited by 007Julien; 10-23-2012 at 06:29 PM.

  3. #3
    Join Date
    Oct 2012
    Posts
    3

    Merci beaucoup Julien

    Merci beaucoup Julien. Maintenant j'ai compris comment écrire correctement ce script. Bonne chance!

  4. #4
    Join Date
    Nov 2012
    Posts
    4
    Agree with above post...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles