Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove first number from string Jquery [closed]

Tags:

jquery

regex

I have string: " 12.3 I love paris 1990".

String I want receive after remove first number is: I love paris 1990

Thank you so much.

like image 865
Hai Tien Avatar asked May 04 '26 01:05

Hai Tien


2 Answers

You can do it using regular expressions as follows,

$('#regxme').text(function(i, txt) {
  return txt.replace(/-?[0-9]*\.?[0-9]+/, '');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<a href="" id="regxme"> 12.3  I love paris 1990</a>
like image 152
ScanQR Avatar answered May 07 '26 18:05

ScanQR


This is the best way for your requirement:

var str = "  12.3  I love paris 1990";
str = $.trim(str)
str = str.substring(str.indexOf(' ')+1);
str = $.trim(str)
alert(str);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
like image 21
rushil Avatar answered May 07 '26 16:05

rushil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!