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

Need regex to match words not within the quotes

Last post 02-18-2008, 11:10 AM by ddrudik. 2 replies.
Sort Posts: Previous Next
  •  02-18-2008, 8:22 AM 39676

    Need regex to match words not within the quotes

    Hi all,

     I am new to the Regex world

     

    I need a regex to match the words "AND/OR/NOT/NEAR/SAME" that is not with in the qoutes

    For Example

    "Printer AND Scanner" OR computer

    should match only the word OR and not the "AND" with in quotes

    Thanks 

     

     

     

     

  •  02-18-2008, 11:10 AM 39678 in reply to 39676

    Re: Need regex to match words not within the quotes

    You could try something like:

    Source Text:
    "Printer AND Scanner" OR NOT computer

    Raw Match Pattern:
    "[^"]*"|(?:(?:AND|OR|NOT|NEAR|SAME) *)+
    
    $matches Array:
    (
        [0] => Array
            (
                [0] => AND 
                [1] => "Printer AND Scanner"
                [2] => OR NOT 
            )
    
    )
    

  •  02-18-2008, 11:10 AM 39679 in reply to 39676

    Re: Need regex to match words not within the quotes

     
View as RSS news feed in XML