Simon
Simon

Reputation: 1476

carriage Return regular expression

Im trying to match a carriage return in a .net regular expression so that we can replace it with a linebreak html tag we currently have:

public readonly static Regex CarriageReturn =
        new Regex(@"^\r*$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

and then use it as:-

StandardRegexes.CarriageReturn.Replace("xxxxxxxx", "<br/>")

this is currently not matching correctly

any advise would be appreciated

Upvotes: 0

Views: 278

Answers (1)

Sadique
Sadique

Reputation: 22821

Try this and check if it works:

\r(?!\n)

Upvotes: 3

Related Questions