Solved

general regular expression for replacing url, in VB.NET

Posted on 2011-02-21
5
339 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 75

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now