regex to match one and only one digit -


i need match single digit, 1 through 9. example, 3 should match 34 should not.

i have tried:

\d \d{1} [1-9] [1-9]{1} [1-9]? 

they match 3 , 34. using regex because part of larger expression in using alternation.

the problem of examples, of course, match digit, don't keep matching multiple digits next each other.

in following example:

some text 3 , 34 , b5 , 64b?

this regex will match lone 3. uses word boundaries, handy feature.

\b[1-9]\b 

it gets more complicated if want match single digits inside words, 5 in example, didn't specify if you'd want that, i'll leave out now.


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 -