I need to get position of the first letter in a string.
Follow a basic example. The first letter is T
, So I need to know the position of T
, for that I can use indexOf("T")
.
I would like to get the first letter by regex instead to add the letter hard-coded (T
).
Thanks in advance.
public class RegexMatches {
public static void main(String args[]) {
String line = "000 1 This is my message";
int first = line.indexOf("T");
line = line.substring(first, line.length());
System.out.println(line);
}
}