Javascript RegExp to match user ID pattern -
i using c# code below detect if string formatted e123456, h123456 or t123456.
regex(@"\b[eht]\d{6}")
i trying use javascript equivalent having difficulties.
so far have, it's returning false each time when should returning true.
regexp("\b[eht]\d{6}")
any appreciated, or link regexp formatting.
i believe issue having due fact when using regexp constructor string argument, special characters such slashes , quotation marks must escaped backslash character. also, use i
flag if want allow both upper , lower case matches.
to make regexp constructor method, use:
new regexp("\\b[eht]\\d{6}", "i")
or make regexp literal, go with:
var regexname = /\b[eht]\d{6}/i
also, if want experiment more regex's in javascript, http://regexr.com/ wonderful site highly recommend!
Comments
Post a Comment