Trying to write a short method so that I can parse a string and extract the first word. I have been looking for the best way to do this.
I assume I would use s
I know this question has been answered already, but I have another solution (For those still searching for answers) which can fit on one line: It uses the split functionality but only gives you the 1st entity.
String test = "123_456";
String value = test.split("_")[0];
System.out.println(value);
The output will show:
123