[Mono-list] C# Regular Expressions Help Urgent

Philip Van Hoof spamfrommailing@freax.org
Sat, 09 Aug 2003 12:27:30 +0200


In Regular Expressions, the [ and ]-chars must be escaped, like :


[freax@pluisje freax]$ cat test.cs
using System;
using System.Text;
using System.Text.RegularExpressions;
 
public class Test
{
   static public void Main ()
   {
       string str_Content="The day is [so bad] for me";

       str_Content = Regex.Replace(str_Content,
             "\\[so Bad\\]",
             "[new replace string]",
             RegexOptions.IgnoreCase);
 
       Console.WriteLine (str_Content);
       return;
    }
}
 
[freax@pluisje freax]$ mono test.exe
´╗┐The day is [new replace string] for me
[freax@pluisje freax]$



On Sat, 2003-08-09 at 12:15, LaVey wrote:
> hi there...
>  
> I am having problems replacing the following string...
>  
> string str_Content="The day is [so bad] for me";
> str_Content = Regex.Replace(str_Content,"[so Bad]","[new replace
> string]",RegexOptions.IgnoreCase);
>  
> how do I replace my "[so bad]" to "[new replace string]"
>  
> regards,
> Nigil
>  
-- 
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
work: Philip dot VanHoof at cronos dot be
http://www.freax.be, http://www.freax.eu.org