You can get it like this:

var suffix = 'comment_like_123456'.match(/\d+/); // 123456

With respect to button:

$('.comment_like').click(function(){
  var suffix = this.id.match(/\d+/); // 123456
});
Answer from Sarfraz on Stack Overflow
🌐
SitePoint
sitepoint.com › blog › javascript › jquery extract numbers from string
jQuery extract numbers from string — SitePoint
February 12, 2024 - To extract numbers from a string and add them together using jQuery, you can use the match() method to extract the numbers, and then use the reduce() method to add them together. The reduce() method reduces an array to a single value by executing a provided function for each value of the array.
🌐
IQCode
iqcode.com › code › javascript › jquery-extract-number-from-string
jquery extract number from string Code Example
October 6, 2021 - var id_of_div = "div_id_12"; var id_number = parseInt(id_of_div.replace(/[^0-9.]/g, "")); console.log(id_number);//12 ... You can get it like this: var suffix = 'comment_like_123456'.match(/\d+/); // 123456 With respect to button: $('.comment_like').click(function(){ var suffix = ...
🌐
EncodedNA
encodedna.com › javascript › how-to-get-numbers-from-a-string-in-javascript.htm
How to Get Numbers from a String in JavaScript
I want to extract the number 4874 from the above string and there are two simple methods to this. Similar example: How to filter out only numbers in an Array using pure JavaScript · &ltscript> var tName = 'arun_4874'; alert(tName.match(/\d+/)); &lt/html> ... The metacharacter \d search for digits, which are also numbers.
🌐
GeeksforGeeks
geeksforgeeks.org › extract-a-number-from-a-string-using-javascript
Extract a Number from a String using JavaScript | GeeksforGeeks
The number from a string in JavaScript can be extracted into an array of numbers by using the match method. This function takes a regular expression as an argument and extracts the number from the string.
Published: January 9, 2025
🌐
Learning jQuery
learningjquery.com › home › 2012 › february
Extract numbers from string using jQuery | Learning jQuery
January 8, 2021 - Today I got into a situation where I need to extract the numbers from the string variable on client side using jQuery. If a string has 1 or more occurrence of the numbers then also need to extract it and store it into an array. For example, if the string is var str = '3jquery33By333Example3333';
🌐
David Walsh
davidwalsh.name › javascript-extract-string
Extract a Number from a String with JavaScript
March 17, 2024 - To employ a regular expression to get a number within a string, we can use \d+: const string = "x12345david"; const [match] = string.match(/(\d+)/); match; // 12345 · Regular expressions are capable of really powerful operations within JavaScript; this practice is one of the easier operations. Converting the number using a Number() wrapper will give you the number as a Number type. ... David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen.
Find elsewhere
🌐
C# Corner
c-sharpcorner.com › code › 508 › find-a-number-from-a-string-and-remove-in-jquery.aspx
Find a number from a string and remove in jQuery
January 30, 2015 - Find a number from a string and remove in JQuery · var str="Sibeesh007" str.replace(str.match(/(\d+)/g)[0], '').trim(); Here str is my string. I hope it helps. find a number from a string and remove in JQuery ·