Regulare expression - test + useful expressions


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var regex = new RegExp(o.validate);
  2. var result = regex.test(value);
  3. // result = true / false
  4.  
  5. //tests
  6. password : /^[a-z0-9_-]{6,18}$/
  7. RGB hex : /^#?([a-f0-9]{6}|[a-f0-9]{3})$/
  8. Email : /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
  9. URL : /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
  10. IP : /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
  11. HTML tag :/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.