Solved

general regular expression for replacing url, in VB.NET

Posted on 2011-02-21
5
338 Views
Last Modified: 2012-05-11
In the related question i've asked previously, i have similar problem in creating regular expression for one more thing.

here is the string, along with the url to be replaced.
"Site": "http://www.google.com/",

Open in new window

String to be replaced is
http://www.google.com/

Open in new window

Format: VB.NET
0
Comment
Question by:herit02
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Terry Woods
ID: 34946680
Do a replace of pattern:
@("""Site"":\s*"")[^""]*("",")
with:
$1 concatenated to your replacement URL concatenated to $2
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 34946683
Given what you've posted, this should suit you:
Dim src As String = """Site"": ""http://www.google.com/"","
Dim rslt As String = System.Text.RegularExpressions.Regex.Replace(src, ".*?""(http://[^""]*).*", "$1")

Open in new window

0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 34946684
Correction:

Do a replace of pattern:
@"(""Site"":\s*"")[^""]*("",)"
with:
$1 concatenated to your replacement URL concatenated to $2
0
 
LVL 3

Author Closing Comment

by:herit02
ID: 34946755
TerryAtOpus,
Same as before, Your work has perfection like diamond!
0
 
LVL 3

Author Comment

by:herit02
ID: 34946763
*not work, i mean solutions.

thanks again!
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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now