tags:

views:

48

answers:

2

Possible Duplicate:
Regex Pattern for a File Name

A user can put a file in the server if the file name matches the following criteria:

It has to be abc or it should start with abc, then a dot, and a number.

Valid file names:    
abc
abc.2344    
abc.111

Invalid:    
abcd
abcd.11    
abc.ab12

What would be the regex? abc.\d+ doesn't have abc to be correct.

+5  A: 
abc(\.\d+)?

The question mark means optional.

Mark Byers
+1  A: 

Make the latter part optional.

abc(\.\d+)?
nullptr