How to remove alpha characters from string using jQuery


 
jQuery for remove alpha characters from string.

If your string is :

var myString = ‘<jainish> 143.8 Text’;

and you want numeric value, dot and dash in your string then you have to use following jQuery

var myString = myString.replace(/[^\d.-]/g, '');
alert(myString)

And output will be :

143.8

If you want only numeric value then Following should do the trick.

var myString = myString.replace(/[^\d]/g, '');
alert(myString)

And output will be :

1438

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

How do i get email from string php


 

For get email id from string. you heve to set reguler expression.

/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i

Below is a exmaple for get email from given string in PHP

<?php

$string = "My email id is jainish.online@gmail.com and also second email id is xyz@gmail.com";

preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);

print(implode("<br>", $matches[0]));

?>

OUTPUT

jainish.online@gmail.com
xyz@gmail.com

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya