0

how can i extract a string until he's first number character? For example i have this string and i want to cut them from the start until the first nummeric ( 1 or 12). The text is dynamic so only the start word is every time the same not the number and not the position of the number.

geschäftsführerin anna maier tannenstraße 12 landau

Captai-N
  • 1,124
  • 3
  • 15
  • 26
  • Possible duplicate of [How to split a string in Java](http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java) – user1803551 Apr 08 '17 at 13:16

1 Answers1

3

You can use the

public String[] split(String regex)

method in String class, just need to pass a regex pattern with numbers like [0-9].

String getSubstringUntilFirstNumber(String source) {
    return source.split("[0-9]")[0];
}
Bogdan Oros
  • 1,249
  • 9
  • 13