Re: Regular expression problem

From: Chris Dutton (rubyguru_at_hotmail.com)
Date: 07/23/04


Date: Fri, 23 Jul 2004 00:33:40 GMT

Joe Ray wrote:
> I am trying to come up with a regular expression that searches and
> replaces all occurences of the string "'" and replaces it with "''" .
> However if a backslash comes before the single quote I do NOT want it
> too be replaced with two single quotes. Any clues?

A zero-width look-ahead assertion should be able to do what you need.

(?<=[^\\]|.{0})'



Relevant Pages

  • Re: Regular expression problem
    ... Joe Ray wrote: ... > However if a backslash comes before the single quote I do NOT want it ...
    (comp.lang.java)
  • Re: how do I extract the ID name of a Div and its content?
    ... got closest to what you were trying, ... example, you might be using the Hpricot (HTML parsing) library, or REXML ... a regular expression which matches a single quote followed by any number ... of non-single-quote characters followed by a single quote. ...
    (comp.lang.ruby)
  • Re: RegularExpression Validation for password in ASP.NET
    ... Can any one help me to write a regular expression to validate the password ... 3- Password must begin with an alphabetic character. ... single quote, double quotes, comma). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: RegularExpression Validation for password in ASP.NET
    ... Can any one help me to write a regular expression to validate the ... 3- Password must begin with an alphabetic character. ... single quote, double quotes, comma). ...
    (microsoft.public.dotnet.framework.aspnet)
  • RegularExpression Validation for password in ASP.NET
    ... Can any one help me to write a regular expression to validate the password ... 3- Password must begin with an alphabetic character. ... single quote, double quotes, comma). ...
    (microsoft.public.dotnet.framework.aspnet)