473,725 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4836
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.Reg ularExpressions
..
..
..
Dim s As String = "Hello|Bla| Foo"
Dim t As String = "He said Hello and Bla or Foo"
MsgBox(Regex.Re place(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******** *************@o 13g2000cwo.goog legroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
39352
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1: domything() And the regexp search assuming no case restriction would be,
2
6479
by: Babu Mannaravalappil | last post by:
Hi, I want to replace some words in my text files (actually transpose). For example, I have a whole lot of expressions (words) in my files as follows: TABLECUSTOMERS TABLEORDERS TABLEORDERLINES ....
4
10199
by: Jane Doe | last post by:
Hi, I need to search and replace patterns in web pages, but I can't find a way even after reading the ad hoc chapter in New Rider's "Inside JavaScript". Here's what I want to do: function filter() { var items = new Array("John", "Jane");
4
62108
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I supposed to write this function? String.replace(/</g,'&lt;');
24
4506
by: Wim Roffal | last post by:
Is there a possibility to do a string replace in javascript without regular experessions. It feels like using a hammer to crash an egg. Wim
10
12139
by: Terry Olson | last post by:
I want to search a textbox and replace any instances of the dollar sign character. But when I do that it thinks it won't work because it think's I'm looking to replace something at the end of the line. How do I tell it to look for literal dollar signs?
2
2379
by: tushar.n.patel | last post by:
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.
32
14876
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
2
5111
by: Dennis | last post by:
I am trying to implement a "Find and Replace" dialog that allows using wildcards in the find string, much like the Find and Replace Dialogs in Ms Word, etc. Are there any references or examples on this. I have tried using the Like comparision operator but about all I can do with it is replace a whole string that contains the wildcard search string. I want to do something like finding *mysea?rch in a string like "This is mysearch string...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8096
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.