473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to omit replacement in somepart of text using regular expression?

How to omit replacement in somepart of text using regular expression?

For ex:

If i want to replace mumbai with mumbai/aaa.com but if i have an anchor tag

<a href="/mumbai/bbb.com>mumbai</a>
then in the anchor tag too the replacement takes place which should not be done..

How to solve this problem?
Nov 7 '08 #1
5 1301
r035198x
13,262 8TB
Post the code you have used for the replacement.
Nov 7 '08 #2
Regex.Replace(str1, m.Result("$2"), sRep);


str1 is the htm file where the string is to get modified and srep is the string that replaces ..
Nov 7 '08 #3
r035198x
13,262 8TB
See the specs for the Replace . There are overloads that allow you to specify how many times the replacement can occur.
Nov 7 '08 #4
Regex.Replace(str1, m.Result("$2"), sRep);


str1 is the htm file where the string is to get modified and srep is the string that replaces ..

can u please write a code for example?
Nov 7 '08 #5
r035198x
13,262 8TB
The code examples are there in the specs for that method. It's just a matter of picking the correct Replace method from the class which also accepts an integer specifying the number of replacements to do.
Nov 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dan | last post by:
Hello, I'd like to be able to take a formatted string and determine the replacement dictionary necessary to do string interpolation with it. For example: >>> str = 'his name was %(name)s and...
13
by: Eddie | last post by:
I need to validate a text input field. I just want to say if user enters 93101 or 93102 or 93103 or 93105 or 93106 or 93107 or 93108 or 93109 or 93110 or 93111 or 93116 or 93117 or 93118 or...
53
by: Kerberos | last post by:
I followed Dan Cederholm's image replacement tutorial, to replace a header tag by a logo. The h1 is clickable if no CSS is applied but it I replace it by the logo, the area isn't clickable anymore...
3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python re.sub(regex, replacement, subject)...
1
by: a_the_s | last post by:
Forethought: I'm using FreeBSD 5.1, gcc 3.2.1 The program takes a string (completely unaware of its contents), parses out HTML, then sends it on its way. Simply put - is there an {easy} way to...
4
by: andrewflanders | last post by:
I have an associative array of keys and values. I want to search a string for the existance of keys and replace them with the values in the array. The problem is that some of the keys resemble...
2
by: brian | last post by:
Hi, before coming to .NET, I utilized regular expressions mostly in JScript / JavaScript and also in my favorite text editor: TextPad (www.textpad.com) I don't know about JScript/JavaScript, but...
4
by: Phil Sandler | last post by:
Hello, What is the fastest/most efficient way of doing string replacement in csharp/.net? An example would be: "Hello, my name is {FirstName}, and I live in the town of {City} with my wife...
1
by: JosAH | last post by:
Greetings, Introduction This week we start building Query objects. A query can retrieve portions of text from a Library. I don't want users to build queries by themselves, because users make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.