2

Currently I have this regex: [\d\.]+ I'm testing it with Regex Hero. You can check it working here.

It correctly reports 5 matches for these values:

1.1.4.3.
11.1.2.4.4.4.5
2
4.4
2.1.1

The problem is that it also matches the final . in the first value 1.1.4.3.

How can I exclude this last . and only match the value 1.1.4.3?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480

2 Answers2

4
^\d+(\.\d+)*$

Should work, assuming two consecutive .s aren't allowed. Otherwise, just change the \. to \.+.

Ry-
  • 218,210
  • 55
  • 464
  • 476
  • I voted for you in the moderator election... and I'll vote again in the next one. :) You're a great guy... can I say a super smart one. Keep helping and you'll learn more and more because is giving that we receive. There's no limit for knowledge. – Leniel Maccaferri Jun 30 '12 at 00:47
1

It sounds like you want:

@"^(\d+\.)*\d+$"
Justin Morgan - On strike
  • 30,035
  • 12
  • 80
  • 104