0

I've got two strings: "EEFFE" and "EEFFFFFFFFFE", is there any regular expression in java such that when I use split get the following array in both strings?: {"EE","E"}.

2
  • Are you trying to return data or just match it Commented Feb 8, 2014 at 2:41
  • Do you also want to split on single F? Commented Feb 8, 2014 at 2:44

2 Answers 2

2

The regex you are looking for is just "F+".

String[] whatINeed = s.split("F+")
Sign up to request clarification or add additional context in comments.

Comments

0

Alternate solution with a slightly different result:

String a = "EEFFE"; 
String b = a.replaceAll("F+", "");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.