List Info

Thread: Newb needs help understanding negating




Newb needs help understanding negating
country flaguser name
United States
2007-03-19 14:05:48
I'm trying to write a regex that matches for
"emacs" but only when not
followed by "Mozilla Firefox". This is what I came
up with:

emacs(?!.*(Mozilla Firefox))

But that didn't work. I also tried

emacs.*(?!(Mozilla Firefox))

But that didn't work either. Same with:

emacs(?!((Mozilla Firefox)$))

What's the right way to do this? :P


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Newb needs help understanding negating
country flaguser name
United States
2007-03-20 10:51:11
I really had trouble with negation too.  It looks like the
characters
in between emacs and Mozilla Firefox are giving you trouble.
 Try this
pattern and see if it works:
emacs(?!([s]?Mozilla Firefox))
Of course this will only work if there is either one or no
spaces
between "Mozilla Firefox" and "emacs".

It really helps if you have a tool that lets you test your
patterns
against text blocks.  I've seen some mentioned in the posts
in this
group, but I can't remember any off the top of my head.

On Mar 19, 12:05 pm, "dataangel" <k04j...gmail.com> wrote:
> I'm trying to write a regex that matches for
"emacs" but only when not
> followed by "Mozilla Firefox". This is what I
came up with:
>
> emacs(?!.*(Mozilla Firefox))
>
> But that didn't work. I also tried
>
> emacs.*(?!(Mozilla Firefox))
>
> But that didn't work either. Same with:
>
> emacs(?!((Mozilla Firefox)$))
>
> What's the right way to do this? :P


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Newb needs help understanding negating
user name
2007-03-21 04:54:23
Here is the pattern i use. It may be possible to improve it but it works for now.
&nbsp;
match(?!(.*?DO not match))(.*?)(match otherstuff)

 
On 3/20/07, munged92 < munged92gmail.com">munged92gmail.com> wrote:

I really had trouble with negation too.  It looks like the characters
in between emacs and Mozilla Firefox are giving you trouble.&nbsp; Try this
pattern and see if it works:
emacs(?!([s]?Mozilla Firefox))
Of course this will only work if there is either one or no spaces
between "Mozilla Firefox&quot; and "emacs".

It really helps if you have a tool that lets you test your patterns
against text blocks.&nbsp; I&#39;ve seen some mentioned in the posts in this
group, but I can't remember any off the top of my head.

On Mar 19, 12:05 pm, "dataangel" < k04j...gmail.com"> k04j...gmail.com> wrote:
>; I'm trying to write a regex that matches for "emacs" but only when not
> followed by "Mozilla Firefox&quot;. This is what I came up with:
>
> emacs(?!.*(Mozilla Firefox))
>
> But that didn't work. I also tried
>
> emacs.*(?!(Mozilla Firefox))
>
> But that didn't work either. Same with:
>
> emacs(?!((Mozilla Firefox)$))
>
> What's the right way to do this? :P


- outsource today
http://www.silasco.net - best computer hardware deals online
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )