1

I know a lot of syntax ( c#,c, vb and so on ) hence my head is pretty full.

So I tend to write regex like this
edit2 : change word RegRex
[0-9]{1,}[aA-zZ]{1,}

[0-9]{1,}[a-zA-Z]{1,}

No +, ?, \d, ...

Is there performance issues with this syntax?

edit : This question is wider than /d vs [0-9] syntax

1 Answers1

2

In terms of performance {1,} and + are equivalent, but the first has more characters to be read... And {1} is not necessary. That won't make much difference though.

More generally, it is not a matter of preference. If you have to match a numeric ID made of numbers from 1 to a big number, without + (or {1,}, or * using \d twice), that will be difficult

\d+

or

[0-9]+

or

[0-9][0-9]*

if you prefer.

Besides, [aA-zZ] matches a, Z (twice actually) and anything between A and z, including [, ], _ ... (see an ascii table)

Tushar
  • 85,780
  • 21
  • 159
  • 179
Déjà vu
  • 28,223
  • 6
  • 72
  • 100