By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,209 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,209 IT Pros & Developers. It's quick & easy.

Search, Replace with Regular Expression

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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.