Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Equal to X not equal to Y

Last post 12-04-2008, 1:37 PM by downatone. 3 replies.
Sort Posts: Previous Next
  •  12-02-2008, 5:04 PM 49067

    Equal to X not equal to Y

    I have 2 strings:

    a) Firefox
    b) Firefox Navigator

    I want my regex to pass if it finds Firefox and not Navigator - so (a)

    I'm trying Firefox[^Navigator] without sucess, any input would be appreciated!

  •  12-02-2008, 5:15 PM 49068 in reply to 49067

    Re: Equal to X not equal to Y

    That is not a clear enough problem description. It is not clear if the string should be rejected if "Navigator" comes right after "Firefox" or should the string "Firefox some other text Navigator" also be rejected? And what about strings that have "Navigator" before "Firefox"? Does case matter or should "fireFOX NavigaTOR" also be rejected? And what about multiple strings or line breaks in between "Firefox" and "Navigator"?

    Anyway, please first check this thread to see if you can solve your problem: http://regexadvice.com/forums/thread/49008.aspx

    If not, feel free to post back with a more detailed question.

    Good luck. 

  •  12-02-2008, 5:41 PM 49069 in reply to 49067

    Re: Equal to X not equal to Y

    Are you attempting to test browser ident strings?  In that case I'm not aware of one that includes both Firefox and Navigator.

    (?=.*\bFirefox\b)(?!.*\bNavigator\b).*

    If it matches then Firefox was found without Navigator, in any order.


  •  12-04-2008, 1:37 PM 49128 in reply to 49069

    Re: Equal to X not equal to Y

    Thanks for the replies.

    Yup, testing browser UA strings, here is an example of one:
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6 

    Was able to use your suggestion above.

    cheers 

View as RSS news feed in XML