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?
5 1331
Post the code you have used for the replacement.
Regex.Replace(s tr1, m.Result("$2"), sRep);
str1 is the htm file where the string is to get modified and srep is the string that replaces ..
See the specs for the Replace . There are overloads that allow you to specify how many times the replacement can occur.
Regex.Replace(s tr1, 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?
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 i saw him %(years)s ago.'
>>> createdict( str )
{'name':'', 'years':''}
>>>
|
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 93120 or 93121 or
93130 or 93140 or 93150 or 93160 or 93190 or 93199 or 93199 or 93401
or 93402 or 93403 or 93405 or 93406 or 93407 or 93408 or 93409 or
93410 or 93412
|
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 when I pass the mouse
over the logo. Is there a way to replace a link by an image that will
still be clickable?
Thanks,
--
Kerberos.
|
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)
method/function, I need the second argument
'replacement' to be another regular expression ( not a
string) . So when I find a 'certain kind of string' in
|
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 evaluate a regular expression on a string, read the results, then replace each of the results?
Technically put...
What I'm trying to do is easily accomplished in perl with something like..
$string_var = s/PATTERN/REPLACEMENT/{flags};
Those used...
| |
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 regular
expressions but they are not so if I build the regular expression with
a constructor it causes errors saying that the regular expression
syntax is bad. I got around this problem by skipping the regular
expression method and passing in the key...
|
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 in TextPad's implementation of
Regular Expressions, you can do a replacement expression like this: \i
For every single non-overlapping match, it places an incrementing number
starting with zero. Thus, if you searched for ^ (beginning of line...
|
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 {WifeName} and my {NumKids} children."
|
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 mistakes. Instead, the Library hands out queries to the user given a simple
query String. This is how the library does it:
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |