Mark S. wrote:
>
> I think he means "02" literally. Usually IP numbers aren't padded, so not
> sure.
>
> It's the range 0-255 that's problematic. Here's what I have for the range:
>
> <option value="^(\b\d\b|\b\d\d\b|1\d\d|2[0-4]\d|25[0-5])">IP range
> 0-256</option>
>
IF that means numbers 000 to 255 it looks doable.
Hmm, I guess with an IP you could add the mandatory delimiter (usually ".")
> and repeat the group. But you would have to manually repeat the group at
> the end where the delimiter must not be.
>
That is quite easy in regex as you can make it just *"\.?"*. Repeat is
easy, just put the dot first on repeats.
And then there's zero padding. Most of the IP numbers I've seen are not
> zero-padded, but ...
>
That is much more difficult in regex. So long as the system throws the 0's
away when not needed it may be okay?
I think the first thing I would do is see what the internet says.
>
> A search for "regular expression ip address" immediately turns up a page
> from O'Reilly, with both a simple
> version and an accurate version for checking IP. As I expected, they're
> able to do a repeat on the structure 3 times, but
> have to do the last one by hand. They've figured out the 0 padding:
>
> ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
>
>
> So ... no need to rebuild the wheel for most common use cases. Hmm, I
> wonder about IPv6 ?
>
> Ok, sorry for the stream-of-consciousness problem-working.
>
Its interesting & useful!
TT
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/f2449494-ad09-44fe-a4f6-ff056496a907%40googlegroups.com.