Sha256: 33fe0739ffe14c1bb49982a44e8b6894d3e839dd3650a4866b5ba4c3d8339266
Contents?: true
Size: 648 Bytes
Versions: 42
Compression:
Stored size: 648 Bytes
Contents
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Acronym { private final String acronym; public Acronym(String phrase) { acronym = generateAcronym(phrase); } public String get() { return acronym; } private String generateAcronym(String phrase){ final Pattern BREAK_WORDS = Pattern.compile("[A-Z]+[a-z]*|[a-z]+"); final Matcher matcher = BREAK_WORDS.matcher(phrase); final StringBuilder b = new StringBuilder(); while (matcher.find()){ b.append(matcher.group().charAt(0)); } return b.toString().toUpperCase(); } }
Version data entries
42 entries across 42 versions & 1 rubygems