469,270 Members | 1,698 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Search, Replace with Regular Expression

hi there!!

i'm looking for a code snipett wich help me to search some words into a
particular string and replace with a perticular word. i got a huge data
string in which searching traditional way mean to secrife lots of time
in asp.net. can any one give me such a expression in which i pass a
data string and search word string and replace word string? if so plz
help me out. i'm in badly need.

Nov 21 '05 #1
4 4563
http://msdn.microsoft.com/library/de...placetopic.asp

Chris.

"lucky" wrote:
hi there!!

i'm looking for a code snipett wich help me to search some words into a
particular string and replace with a perticular word. i got a huge data
string in which searching traditional way mean to secrife lots of time
in asp.net. can any one give me such a expression in which i pass a
data string and search word string and replace word string? if so plz
help me out. i'm in badly need.

Nov 21 '05 #2
Lucky

A lot of snippets and explanations on these pages

RegexLib
http://www.regexlib.com/Default.aspx

Expresso
http://www.ultrapico.com/Expresso.htm

I hope this helps a little bit?

Cor
Nov 21 '05 #3
"lucky" <tu************@gmail.com> schrieb:
i'm looking for a code snipett wich help me to search some words into a
particular string and replace with a perticular word. i got a huge data
string in which searching traditional way mean to secrife lots of time
in asp.net. can any one give me such a expression in which i pass a
data string and search word string and replace word string?


\\\
Imports System.Text.RegularExpressions
..
..
..
Dim s As String = "Hello|Bla|Foo"
Dim t As String = "He said Hello and Bla or Foo"
MsgBox(Regex.Replace(t, s, ""))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
lucky,
Do you want to replace a list of words with a single word, or replace a list
of words with an alternate list of words?

Did you look up RegEx.Replace in the online help?

http://msdn.microsoft.com/library/de...placetopic.asp

This topic provides a sample:
http://msdn.microsoft.com/library/de...laceTopic1.asp

Here is an example of replacement patterns:

http://msdn.microsoft.com/library/de...ateformats.asp

General information on Regular Expressions:
http://msdn.microsoft.com/library/de...xpressions.asp

For replacing a list with a list I normally use the overload that accepts a
MatchEvaluator. For replacing a list with a single word I normally use the
overload that accepts a single string. I have not used replacement patterns
yet...

Expresso & RegEx Workbench both have wizards of varying degrees to help you
build your expression, plus they allow you to test your expressions, also
the analyzer/interpreter in each is rather handy.

Expresso:
http://www.ultrapico.com/Expresso.htm

RegEx Workbench:
http://www.gotdotnet.com/Community/U...-4ee2729d7322A

tutorial & reference on using regular expressions:
http://www.regular-expressions.info/

The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/de...geElements.asp

Hope this helps
Jay

"lucky" <tu************@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
hi there!!

i'm looking for a code snipett wich help me to search some words into a
particular string and replace with a perticular word. i got a huge data
string in which searching traditional way mean to secrife lots of time
in asp.net. can any one give me such a expression in which i pass a
data string and search word string and replace word string? if so plz
help me out. i'm in badly need.

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Anand Pillai | last post: by
4 posts views Thread by Jane Doe | last post: by
4 posts views Thread by higabe | last post: by
24 posts views Thread by Wim Roffal | last post: by
10 posts views Thread by Terry Olson | last post: by
2 posts views Thread by tushar.n.patel | last post: by
32 posts views Thread by tshad | last post: by
2 posts views Thread by Dennis | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.