Regular expression to replace a string that is not in a quoted substring.

Posted on 2009-02-09
Last Modified: 2012-05-06
Is it possible to replace all letters "a" that are outside all quoted strings with "&".
E.g. Debug.Print(
Regex.replace("And Don't Forget&Experts love to get the ""answer""""s accepted"" as the solution to your question.", <some pattern>
should print
&nd Don't Forget&Experts love to get the "answer""s accepted" &s the solution to your question.

I don't know what the pattern might be to SKIP some matches (quoted strings) while searching for others (just "a").
Question by:midfde
    1 Comment
    LVL 84

    Accepted Solution



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now