Solved

general regular expression for replacing url, in VB.NET

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

828 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