Tuesday, 15 May 2012

javascript - Validate Regex with minimum length and new line -



javascript - Validate Regex with minimum length and new line -

i trying match string having length > 10

var value = "lorem ipsum dummy text of printing , type"; /^.{10,}$/.test(value);

returns true;

but, if have string new line character fails.

how can update regular look prepare that.

i know can check .length > 10 or replace new line space in value. but, want update regular expression.

if it's length you're testing should utilize .length. if insist in regex, dot matching except newline. can alter searching \s\s instead:

([\s\s]{10,})

this matches whitespace , non whitespace, covering entire spectrum. sadly, s modifier not supported js regex.

javascript

No comments:

Post a Comment