Sha256: 9b1ea6298d49c8e0fd565ca5b450fd2a3a133168f01e9dea147b76acde88923c
Contents?: true
Size: 469 Bytes
Versions: 125
Compression:
Stored size: 469 Bytes
Contents
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Acronym { public static String generate(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
125 entries across 125 versions & 1 rubygems