bones.felipe
bones.felipe

Reputation: 596

Split many single character with regex (java)

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"}.

Upvotes: 0

Views: 77

Answers (2)

Caboose
Caboose

Reputation: 463

Alternate solution with a slightly different result:

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

Upvotes: 0

Chthonic Project
Chthonic Project

Reputation: 8366

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

String[] whatINeed = s.split("F+")

Upvotes: 2

Related Questions