Reputation: 277
I have strings having special characters e.g.
"ravi", "Ravi" ,"!ravi","ravi...","RaVi)" etc..
I want all these to be treated as same. How to achieve this. Can be in shell script, C,C++,JAVA.
Thanks, Ravi.
Upvotes: 1
Views: 3579
Reputation: 425043
Java: str.toLowercase().replace("[^a-zA-Z]", "")
will render them all in lowercase with special chars removed and therefore all equal()
Edited to cover everything not alpha as "special"
Upvotes: 3
Reputation: 31722
Use find function of String in c++ to find the occurrence of your substring in your case "ravi".
size_t find ( const string& str, size_t pos = 0 ) const;
It will return you starting index of your substring in main string.
by using that information, you could manipulate the string as per your requirement.
Upvotes: 0