Given a string like String a="- = - - What is your name?";
How to remove the leading equal, dash, space characters, to get the clean text,
“What is your name?”
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to remove the leading non-alphabets you can match:
and replace it with
''(empty string).Explanation:
first ^– Anchor to match at thebegining.
[]– char classsecond ^– negation in a char class+– One or more of the previous matchSo the regex matches one or more of any non-alphabets that are at the beginning of the string.
In your case case it will get rid of all the leading spaces, leading hyphens and leading equals sign. In short everything before the first alphabet.