ciao a tutti,
so che esitono molti post sull'argomento, ma la mia domanda serve per capire.
allora, mi sono creato un form html così
dopo ho inserito nel'input x la reg expcodice:<html> <head> </head> <script> function test() { str=document.formm.textfield.value; var reg = new RegExp(document.formm.regx.value); alert(reg.exec(str)); } </script> <body> <form name="formm"> REGEXP <input type="text" name="regx"> </p> STRINGA <input name="textfield" type="text"></p> </p> <input type="button" name="Submit" value="Invia" onClick="test()"> </p> </form> </body> </html>
^[a-z0-9\-\_]*\@[a-z0-9\-]+(.it|.com|.net|.org)
e come stringa
pippo@pippo.it
perchè esce un'alert che mi dà 2 risultati e non uno solo?
risultato dell'alert è "pippo@pippo.it,.it"