Search:
Namespaces
Discussions
.NET v1.1
Feedback
Using Replace - Not working right
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngregexp' list
.
Matt Moore
I am using the
Regex
.Replace function and it is not working properly.
Here is the code.
n = dr["name"].ToString();
msg =
Regex
.Replace(msg, "[[name]]", n);
msg is a HTML email that will be sent. I am trying to replace the "[[name]]" with the name from the data base but these are the results:
"Your name is going to be inserted right here: [[namMatt] . .............."
It replaced the "e]" but no the rest of the name tag. Do you have any ideas?
Thanks
Matt
Reply to this message...
Wayne King
Have you considered just using the
String
.Replace() method? From the =
description of the problem, it sounds like you may not need to use =
regular expressions.
msg =3D msg.Replace("[[name]]", n);
You're not seeing the results you expect because your pattern contains =
special regex characters. The sequence [[name] means, 'match one =
character that is either a left square bracket, an n, an a, an m, or an =
e.' If you really want to use a regex, this should work for you:
msg =3D
Regex
.Replace(msg, "\[\[name]]", n);
-----Original Message-----
From: Matt Moore [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, May 16, 2002 2:36 PM
To: aspngregexp
Subject: [aspngregexp] Using Replace - Not working right
-- Moved from [aspngfreeforall] to [aspngregexp] by devin rader =
<
Click here to reveal e-mail address
> --
I am using the
Regex
.Replace function and it is not working =
properly.=3D20
=3D20
Here is the code.=3D20
=3D20
n =3D3D dr["name"].ToString();
msg =3D3D
Regex
.Replace(msg, "[[name]]", n);
=3D20
msg is a HTML email that will be sent. I am trying to replace the =3D
"[[name]]" with the name from the data base but these are the results:
=3D20
"Your name is going to be inserted right here: [[namMatt] . =3D
.............."
=3D20
It replaced the "e]" but no the rest of the name tag. Do you have any =
=3D
ideas?
=3D20
Thanks
Matt
Reply to this message...
System.String
System.Text.RegularExpressions.Regex
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com