java - How to Determine if a String starts with exact number of zeros? -


how can know if string starts {n} number of leading zeros? example below, conditions return true real intention check if string starts 2 zeros.

string str = "00063350449370"  if (str.startswith("00")) { // true     ... } 

you can like:

if ( str.startswith("00") && ! str.startswith("000") ) {    // .. } 

this make sure string starts "00", not longer string of zeros.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -