Given an alphanumeric string, extract maximum numeric value from that string. Alphabets will only be in lower case.
Input : 100klh564abc365bg Output : 564 Maximum numeric value among 100, 564 and 365 is 564. Input : abchsd0sdhs Output : 0
This problem has existing solution please refer Extract maximum numeric value from a given string | Set 1 (General approach) link. We will solve this problem quickly in python using Regex. Approach is very simple,
- Find list of all integer numbers in string separated by lower case characters using re.findall(expression,string) method.
- Convert each number in form of string into decimal number and then find max of it.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Extract maximum numeric value from a given string | Set 2 (Regex approach)
- Extract maximum numeric value from a given string | Set 1 (General approach)
- Python - Maximum Pair Summation in numeric String
- Find all the patterns of “1(0+)1” in a given string using Python Regex
- The most occurring number in a string using Regex in python
- Python | Extract words from given string
- Python | Extract only characters from given string
- Python | Extract digits from given string
- Python | Extract numbers from string
- Python | Extract characters except of K string
- Python | Check if string matches regex list
- Python | Extract Numbers in Brackets in String
- Python | Extract odd length words in String
- Python | Extract Score list of String
- Python Regex - Program to accept string starting with vowel
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.