Sha256: 81f2c0486284a117b56e4b890f78159c5766c5967da5c797e8238042018cc768
Contents?: true
Size: 636 Bytes
Versions: 112
Compression:
Stored size: 636 Bytes
Contents
import java.util.regex.Matcher; import java.util.regex.Pattern; final class Acronym { private final String acronym; Acronym(String phrase) { acronym = generateAcronym(phrase); } 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
112 entries across 112 versions & 1 rubygems