1
^[a-zA-Z]:{1}/(\w+/)+$

I want to allow . as well in the expression in \w+. How can I do this?

strager
  • 88,763
  • 26
  • 134
  • 176
maztt
  • 12,278
  • 21
  • 78
  • 153
  • 1
    `{1}` is completely redundant, by the way, `:{1}` makes **:** match only once, which is the same as `:`. – Kobi Jul 08 '10 at 09:06
  • To add to Kobi's excellent point: http://stackoverflow.com/questions/3032593/using-explicitly-numbered-repetition-instead-of-question-mark-star-and-plus – polygenelubricants Jul 09 '10 at 10:58

4 Answers4

9

\. should do it. You don't need the escaping \ if you put it in a character class. For your exact example:

^[a-zA-Z]:{1}/([\w.]+/)+$
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
3

The . is a special character in regular expression syntax, so you have to escape it with a backslash. \.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
1

Replace

(\w+/)

with

([\w.]+/)
strager
  • 88,763
  • 26
  • 134
  • 176
-1

The expression should be ^[a-zA-Z]:/(\w+./)+$ or ^[a-zA-Z]:/([\w.]+/)+$

serhio
  • 28,010
  • 62
  • 221
  • 374