Extracting integers from string of text in Java -
this question has answer here:
- extract digits string in java 12 answers
i have several lines of text such as:
"you current have 194764bleh notifications" "you current have 32545444bleh notifications" "you current have 8132bleh notifications" "you current have 93bleh notifications"
what's best way integers text ?
currently using line.split
twice, once "have" , once "bleh".
seems inefficient doing integers.
are there better ways that?
e.g.
string str = "you current have 194764bleh notifications"; str = str.replaceall("\\d", ""); // replace non-digits
using regex take away non-digits option,
not restrict having 'have' & 'bleh' wrap numbers.
not entirely sure efficiency compared using split though.
Comments
Post a Comment