Solved

general regular expression for replacing url, in VB.NET

Posted on 2011-02-21
5
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…

617 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