Arun Killu
Arun Killu

Reputation: 14243

Regular expression compilation fail error

regex '/^[0-9]{5}+\.[0-9]{3}+\.[0-9]{5}+(\.[0-9]{4}){4}/'

string 00000.000.10115.0000.5210.9002.0000

I think the regex that i created is wrong can someone correct me.

Upvotes: 0

Views: 79

Answers (1)

falsetru
falsetru

Reputation: 369274

Multiple repeat is not valid. Drop + after {..}:

'/^[0-9]{5}\.[0-9]{3}\.[0-9]{5}(\.[0-9]{4}){4}/'

BTW, you can replace [0-9] with \d:

'/^\d{5}\.\d{3}\.\d{5}(\.\d{4}){4}/'

Upvotes: 3

Related Questions