in reply to Regex Validation
The magic you need is to look around. Consider:
use strict; use warnings; my @tests = ( 'sip:userid@example.com', 'sip::userid@example status::code', '::', '::a::', ':::bad_example::', ); print /^([^:]|(?<!:)::(?!:))+$/ ? "OK $_\n" : "NO $_\n" for @tests;
BTW, the flack you got was for not (obviously) showing what you had tried. Although you did actually show [^:]+, because you didn't bother with code tags the square brackets turned the ^: into a link. There is a strong requirement here for supplicants to demonstrate that they have actually had a go at solving the problem themselves by showing the code they have tried.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Validation
by AnomalousMonk (Archbishop) on Jul 30, 2009 at 03:18 UTC |