Given a string str, divide the string into three parts one containing a numeric part, one containing alphabetic and one containing special characters.
Input : geeks01for02geeks03!!! Output :geeksforgeeks 010203 !!! Here str = "Geeks01for02Geeks03!!!", we scan every character and append in res1, res2 and res3 string accordingly. Input : **Docoding123456789everyday## Output :Docodingeveryday 123456789 **##
- Calculate the length of the string.
- Scan each every character(ch) of a string one by one
- if (ch is a digit) then append it in res1 string.
- else if (ch is alphabet) append in string res2.
- else append in string res3.
- Print the all the strings, we will have one string containing numeric part, other non numeric part and last one contain special characters.
geeksforgeeks 010203 $$!@!!
Time complexity of above solution is O(n) where n is the length of the string.
This article is contributed by Rishabh Jain. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Remove uppercase, lowercase, special, numeric, and non-numeric characters from a String
- Check if a string contains uppercase, lowercase, special characters and numeric values
- Print all the palindromic permutations of given string in alphabetic order
- Find the largest Alphabetic character present in the string
- Count Uppercase, Lowercase, special character and numeric values
- Split a Numeric String into Fibonacci Sequence
- Find the count of substrings in alphabetic order
- Check whether the given character is in upper case, lower case or non alphabetic character
- Parsing String of symbols to Expression
- How to find index of any Currency Symbols in a given string
- WildCard pattern matching having three symbols ( * , + , ? )
- Program to count vowels, consonant, digits and special characters in string.
- Extract maximum numeric value from a given string | Set 1 (General approach)
- Extract maximum numeric value from a given string | Set 2 (Regex approach)
- Python Regex to extract maximum numeric value from a string
- Splitting a Numeric String
- Longest Subsequence from a numeric String divisible by K
- Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings
- Reverse a string without affecting special characters
- Count special palindromes in a String