java - Extract first found int from String -


so have strings 22test12344dc , 1name23234343dc

i want best way extract first found full int string.

so return 22 , 1 above examples. first full int's found

i tried way, don't want values after first char.

mystr.split("[a-z]")[0] 

try this.

string s = "22test12344dc"; string firstint = s.replacefirst(".*?(\\d+).*", "$1"); system.out.println(firstint); 

result:

22 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -