Hi guys ,

I have a number format like nn.nn.nn and nn.nn.
I want to write a regex t check either one of them exist or not.

I wrote this

^(\d\d).(\d\d)$

but it only applies to nn.nn. Since i'm not ood in regex. i couldnt think a way to check both formats with in the same reg ex.

Hope you guys can help me.

thanks

Recommended Answers

All 2 Replies

@"^(\d\d\.\d\d|\d\d\.\d\d\.\d\d)$"

You need to escape the . or it will match things like 02a34.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.