Answers for "get number out of string"

3

js get number from string

thenum = "foo3bar5".match(/\d+/)[0] // "3"
Posted by: Guest on January-08-2021
1

java get number out of string

for(int i=0; i<yourString.length();i++) {
  if(Character.isDigit(yourString.charAt(i))) {
    // Do something with the number
    // For example convert it to int:
    int yourNumber = Integer.parseInt(String.valueOf(yourString.charAt(i)));
  }
}
Posted by: Guest on May-25-2021

Code answers related to "get number out of string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language