tags:

views:

109

answers:

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

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

+9  A: 

\. 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
+3  A: 

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

Bill the Lizard
+2  A: 

Replace

(\w+/)

with

([\w.]+/)
strager
A: 

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

serhio
Um, no? Now you're matching one alnum character `\w` and any character `.` where the OP wants one or more alnums or dots, followed by a slash, repeated once or more.
Tim Pietzcker
I didn't downvote, but as I wrote above, your answer is plain wrong.
Tim Pietzcker
understood. thanks! I thought for a moment that \w is for a word
serhio