I\'m trying to get the first letter of each word in a string using regex, here is what I have tried:
public class Test { public static void main(String[]
It's not fixing the regex, but adding a .trim() to the output string still works:
String name = "First Middle Last"; for(String s : name.split("(?<=[\\S])[\\S]+")) System.out.println(s.trim());
output:
F M L