In this article, we will learn how to move all special char to the end of the String.
Input : !@$%^&*AJAY
Input :Geeksf!@orgeek@s A#$ c%o^mputer s****cience p#o@rtal fo@r ge%eks
Output :Geeksforgeeks A computer science portal for geeks!@@#$%^****#@@%
Prerequisite : Regular Expressions in Java
The idea is to traverse input string and maintain two strings, one string that contains normal characters (a, A, 1, ‘ ‘, etc) and other string that maintains special characters (@, $, etc). Finally, concatenate the two strings and return.
Here is the implementation of above approach
Geeksforgeeks A computer science portal for geeks!@@#$%^****#@@%
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.
- Move all Uppercase char to the end of string
- Count special palindromes in a String
- Reverse a string without affecting special characters
- Split numeric, alphabetic and special symbols from a String
- Check if a string can be rearranged to form special palindrome
- Move all occurence of letter 'x' from the string s to the end using Recursion
- Calculate Sum of ratio of special characters to length of substrings of the given string
- Move spaces to front of string in single traversal
- Program to count vowels, consonant, digits and special characters in string.
- Minimum swaps required to move all vowels occurs after consonants in a given string
- Python code to move spaces to front of string in single traversal
- Convert string to char array in C++
- Sum of special triplets having elements from 3 arrays
- Number of special pairs possible from the given two numbers
- Sudo Placement | Special Subsequences
- __file__ (A Special variable) in Python
- Count the number of special permutations
- Count the number of Special Strings of a given length N
- Inverting the Move to Front Transform
- Find Largest Special Prime which is less than or equal to a given number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.