RewriteRule...just need to match any number of numbers and 2 periods

Hi,

I’m implementing mod_rewrite and need to rewrite URL’s in the form:

123.4567.89

where the period could be anywhere in the string except the beginning or end, but there will always be 2. There can be any number of number digits.

I thought that the following would work:

([0-9]+\.{2})

but it doesn’t. What might I be doing wrong? I can get

([0-9\.]+) to work, or even ([0-9\.{2}]+), but either of those match more than 2 periods.

Thanks in advance.

Yes, dklynn, you are exactly right. That worked and was a more specific pattern match than I had initially described. Thanks! I’m new to mod_rewrite and regular expressions, but this has opened my eyes to a different way of thinking about them.

un,

Aw, I’d say it’s all in the wrist but it’s really how well you understand regular expressions. First, verbalize what you’re trying to do (as I did above) then translate that to code in a regular expression.

Regards,

DK

un,

You got it! The reason a character range definition won’t work for you is that it defines the set of characters for the entire range (as specified by the range modifier whethe it be ?, +, * or {x,y}. What you seem to want to do it capture three series of digits separated by two dot characters, isn’t it? Doesn’t that seem more like (\d+)\.(\d+)\.(\d+) ? Three sets of one or more digits separated by dot characters and each digital set is addressable by $1, $2 or $3. What more could you ask for … once you can verbalize what you’re trying to do?

Regards,

DK