Javascript examples for String Operation:String Split
Split a string at special character via split method and regex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*www.j a va 2 s .c om*/ var letters = "jon-doe@email.com"; var email = letters.substr(0, letters.indexOf('@')); var parts = email.split(/[^A-Za-z]/); console.log(parts); } </script> </head> <body> </body> </html>