Jeff Schoolcraft
4/15/2008 1:42:00 PM
I don't think you'll be able to do what you want with just a regex pattern.
The closest you could get is negative lookahead. You'd have to pull out th=
e
first character and use negative lookahead for the rest, it will probably
only work for simple strings.
irb(main):029:0> a =3D "Hello World"
=3D> "Hello World"
irb(main):030:0> a =3D~ /h(?!ello)/i
=3D> nil
irb(main):031:0> b =3D "Hel l o world"
=3D> "Hel l o world"
irb(main):032:0> b =3D~ /h(?!ello)/i
=3D> 0
On Tue, Apr 15, 2008 at 9:17 AM, Dipesh Batheja <dipesh_batheja@yahoo.com>
wrote:
> Problem is i have function, which takes a regex as the parameter. I want
> to pass this regex in such a way that the function returns false if the
> string is matched and true if it isn't. I want the regex itself specify
> that if it matches the given string then it is false otherwise true.
>
> Jes=FAs Gabriel y Gal=E1n wrote:
> > On Tue, Apr 15, 2008 at 2:59 PM, Dipesh Batheja
> > <dipesh_batheja@yahoo.com> wrote:
> >> Can somebody hep me with a very simple regular expression. I want to
> >> write an regex which if matches a specific string should return false=