Connecting Tech Pros Worldwide Help | Site Map

Search, Replace with Regular Expression

lucky
Guest
 
Posts: n/a
#1: Nov 21 '05
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.

Chris Podmore
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Search, Replace with Regular Expression


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

Chris.

"lucky" wrote:
[color=blue]
> 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.
>
>[/color]
Cor Ligthert
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Search, Replace with Regular Expression


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


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Search, Replace with Regular Expression


"lucky" <tushar.n.patel@gmail.com> schrieb:[color=blue]
> 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?[/color]

\\\
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/>
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Search, Replace with Regular Expression


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" <tushar.n.patel@gmail.com> wrote in message
news:1107932947.812419.56690@o13g2000cwo.googlegro ups.com...[color=blue]
> 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.
>[/color]


Closed Thread