Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

general regular expression for replacing url, in VB.NET

Posted on 2011-02-21
5
Medium Priority
?
347 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…

886 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