0

I wish to accept hex characters only, case doesn't matter, so [0-9a-fA-F] but I only want to accept strings between 10 and 64 characters, what is the best way to do this range?

I am using POSIX Basic Regular Expressions.

Rui Jarimba
  • 11,166
  • 11
  • 56
  • 86
Paul
  • 5,756
  • 6
  • 48
  • 78

3 Answers3

3

Use quantifiers

^[0-9a-fA-F]{10,64}$

w{n} means match w n times exactly where n is a positive number

w{n,m} means match w between n to m times

w{n,} means match w n to many times

^ is start of the string

$ is end of the string

Now here ^,$ are essential else it would match anywhere in between

Anirudha
  • 32,393
  • 7
  • 68
  • 89
2

You can give a range in braces.

^[0-9a-fA-F]{10,64}$
Tarandeep Gill
  • 1,506
  • 18
  • 34
1

Try this:

^[0-9a-fA-F]{10,64}$
Matheus
  • 281
  • 2
  • 5