I want to retrive the number sequence which is at the end of string. for e.g.
string contentDbIndex = Regex.Match("ab56cd1234", @"\d+").Value;
gives me result 56
but I want the result as 1234
. How should I do this ?
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. Regular expression for extracting a number is (/(\d+)/).
To check if a string ends with a number, call the test() method on a regular expression that matches one or more numbers at the end a string. The test method returns true if the regular expression is matched in the string and false otherwise.
The endswith() method returns True if the string ends with the specified value, otherwise False.
You can use a end anchor ($
) like this:
string contentDbIndex = Regex.Match("ab56cd1234", @"\d+$").Value;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With