Google Answers Logo
View Question
 
Q: Need RegEx (Regular Expression) for ASP C# application to edit links in content ( No Answer,   0 Comments )
Question  
Subject: Need RegEx (Regular Expression) for ASP C# application to edit links in content
Category: Computers > Programming
Asked by: mpower1313-ga
List Price: $50.00
Posted: 21 Oct 2005 00:38 PDT
Expires: 21 Oct 2005 04:40 PDT
Question ID: 582962
I am looking for a regular expression to be used in C# code to
dynamically add onClick event tags to links.

1. Checks all links in a text for the existence of onClick="" and
2. Adds an onClick="" based on the information to be found within the
link tag when an onClick tag is not already in the text.

We start with the following text:

-----
Lorem ipsum dolor sit amet, <A
href="/NR/rdonlyres/37FA59DC-AA7A-412D-BC82-D107E85303D4/0/5_reasearch.gif">consectetuer</A>
adipiscing elit. Morbi congue ullamcorper purus. Lorem ipsum dolor sit
amet, consectetuer adipiscing elit. In sit amet orci. Integer luctus.
Ut imperdiet elit id ligula accumsan adipiscing. Cras fringilla felis
ut ligula. Donec malesuada, lorem non feugiat sodales, nulla massa
euismod libero, nec ultricies ipsum ante ac quam. Phasellus accumsan,
odio vitae interdum faucibus, leo mauris adipiscing justo, ac sagittis
purus ante nec dui. Donec <A
href="/NR/rdonlyres/C7EDED1C-E826-41A8-9187-CB4B0C2781EA/0/redbear.gif"
onclick="doThis();">laoreet</A>. Proin bibendum, justo in faucibus
feugiat, lorem diam consectetuer pede, id sagittis nibh quam in purus.
Duis ultrices, turpis in pulvinar dignissim, leo lectus lacinia nibh,
in varius magna purus ac <A
href="/NR/rdonlyres/735C0F09-60F9-4CB8-B347-9942FA6898DE/0/Upgradesite.doc"
target="_blank">presentationdiam</A>. Etiam libero orci, congue eu, <A
href="/ETV/">ullamcorper</A> sit amet, congue non, lacus. Nam
sagittis, risus eget pretium molestie, augue mauris vehicula tortor,
sit amet ultricies neque est vitae lorem. In leo. Suspendisse potenti.
-----

The resulting text should be:

-----
Lorem ipsum dolor sit amet, <A
href="/NR/rdonlyres/37FA59DC-AA7A-412D-BC82-D107E85303D4/0/5_reasearch.gif"
onclick="dcsMultiTrack('DCS.dcsuri','/NR/rdonlyres/37FA59DC-AA7A-412D-BC82-D107E85303D4/0/5_reasearch.gif','WT.ti','5_reasearch.gif
(consectetuer)')">consectetuer</A> adipiscing elit. Morbi congue
ullamcorper purus. Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. In sit amet orci. Integer luctus. Ut imperdiet elit id ligula
accumsan adipiscing. Cras fringilla felis ut ligula. Donec malesuada,
lorem non feugiat sodales, nulla massa euismod libero, nec ultricies
ipsum ante ac quam. Phasellus accumsan, odio vitae interdum faucibus,
leo mauris adipiscing justo, ac sagittis purus ante nec dui. Donec <A
href="/NR/rdonlyres/C7EDED1C-E826-41A8-9187-CB4B0C2781EA/0/redbear.gif"
onclick="doThis()">laoreet</A>. Proin bibendum, justo in faucibus
feugiat, lorem diam consectetuer pede, id sagittis nibh quam in purus.
Duis ultrices, turpis in pulvinar dignissim, leo lectus lacinia nibh,
in varius magna purus ac <A
onclick="dcsMultiTrack('DCS.dcsuri','/NR/rdonlyres/735C0F09-60F9-4CB8-B347-9942FA6898DE/0/Upgradesite.doc','WT.ti','Upgradesite.doc
(presentationdiam)')"
href="/NR/rdonlyres/735C0F09-60F9-4CB8-B347-9942FA6898DE/0/Upgradesite.doc"
target="_blank" >presentationdiam</A>. Etiam libero orci, congue eu,
<A  onclick="dcsMultiTrack('DCS.dcsuri','/ETV/','WT.ti','ETV
(ullamcorper)')" href="/ETV/">ullamcorper</A> sit amet, congue non,
lacus. Nam sagittis, risus eget pretium molestie, augue mauris
vehicula tortor, sit amet ultricies neque est vitae lorem. In leo.
Suspendisse potenti.
-----

Note: the <DCS.uri> should show the URL used in the link tag. The
<WT.ti> should be the part of the link after the last slash (note that
the link could end with a slash) and with within brackets the text
that is between the link tags.

onclick="dcsMultiTrack('DCS.dcsuri','<DCS.dcsuri>','WT.ti','<WT.ti>');"

I need this RegEx quite urgently. If you have questions, do not hesitate to ask.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy