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
Post a Comment