javascript - Regular expression not supporting line skipping \n -


i'm trying find right regular expression number line skip @ end ( \n ) every time it's not working.

my regular expression /^\d+(\n)$/.

edit : text area contains :

22\n 33 

here's code ( i'm trying validate what's in textarea , it's numbers going there \n @ end of each lines ) :

function validechamp() {   var rexp1 = /^\d+(\n)$/;   var achamps = document.queryselector("textarea").value;    if (rexp1.test(achamps.value)==true){     alert("valide")    }      else {        alert("invalide")     return false;      }    } 

if want check line containing number on it, can use:

/(^|\n)\d+(\r?\n)/ 

if want check there's number, , newline, , nothing else:

/^\d+(\r?\n)$/ 

(which checking for, that's odd input pattern.)

if want make sure textarea has lines numbers, might simpler check string.replace(/[0-9\r\n]/g, '') == ''. confirm if contains numbers , newlines.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -