Hi,
I have one text like below it was stored on variable
var a='My no is 12345'
my requirement is that how to store only number on another varaible from that text
var b=12345
could you please help me
Hi mahesh213,
Use substring function.
Refer below code.
HTML
<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <script> window.onload = function () { var a = 'My no is 12345'; alert(a.substring(a.lastIndexOf(" ") + 1, a.length)); } </script> </head> <body> </body> </html>
Demo
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.