How can I know if a Char is a digit?

  • Thread starter Thread starter Guest
  • Start date Start date
If you need to check a set of characters, a regular expression will do the
trick more easily than looping through the characters in the string, testing
each one.
 
Dan,

The regular expression might do it more easily, but if you don't know
regular expression syntax, the looping is easier to code. I personally have
always had a great deal of trouble relaly understanding regular expression
syntax in Unix or in .NET. But that's just me.

Pete
 
Dave Veeneman said:
If you need to check a set of characters, a regular expression will do the
trick more easily than looping through the characters in the string, testing
each one.

Indeed it will - and in simple cases it may be more easily readable
too. In other cases, however, it'll be less readable as the regular
expression becomes harder to understand to the human eye. Also, using
straight code will be significantly faster, if performance is an issue.
(Performance should only be taken into consideration when it's actually
proved to be problematic.)
 
Back
Top