Solved

Regex: Inserting a quote character into link with grepWin tool

Posted on 2011-09-30
4
260 Views
Last Modified: 2012-05-12
Hello Experts,

I have links I need to update that exist in the html pages as  

<a href="www.site.com/xxxxx>

Open in new window


the xxxxx is different in every link but is always some letters or numbers. I was able to piece together a Regex search string to find the string which contains the portion I need:

 
www.site.com/(.*?>)

Open in new window


This will match a result that looks like:

 
www.site.com/subdirectory>

Open in new window


Perfect. But, I am lost on what to use in my Regex replace string to insert the quote symbol just before the wicket. Thanks in advance for your assistance.
0
Comment
Question by:JF0
  • 2
4 Comments
 
LVL 6

Expert Comment

by:Dangle79
Comment Utility
short of digging into it because my brain is far from that mode right now, this is the tool i use for building and evaluating regex strings

http://gskinner.com/RegExr/

easy to use and pretty slick
0
 
LVL 16

Author Comment

by:JF0
Comment Utility
I was looking at that earlier, but it didn't help me find the correct answer. After some further research I think I need to use something called backreferences. I am so lost.

I basically want to match everything before the wicket, and replace it with everything before the wicket + a quote character.
0
 
LVL 10

Accepted Solution

by:
mark_harris231 earned 500 total points
Comment Utility
Match String: www.site.com/(.*?)>  (matches everything after the backslash to the ending wicket)

Replace string:  www.site.com/$1">

Depending on the regex engine you are using, you may need to use \1 instead of $1
0
 
LVL 16

Author Closing Comment

by:JF0
Comment Utility
Perfect, thanks!

I couldn't think of how to set the sub dir as the reference - seems so simple now.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now