Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
Hi, need help for a regular expression, cant really figure ir out myself.
I have a website, for example and I use this code to read the content of the website.
 StreamReader webSource = new StreamReader(webResponse.GetResponseStream());
                    string source = webSource.ReadToEnd();
So I need a regular expression match to find all the containig website url`s that are within the server. So I need to find all theese kind of links:");");;search=bcc6928a29fe348a30cbfc2dc1aba4ab&place=1");
And i dont want to find links like
Can anyone help with this?
Posted 26-Dec-12 9:15am
Zoltán Zörgő at 26-Dec-12 15:21pm
- "url`s that are within the server" makes no sense, since you fetch only a single page, without references.
- you havce specified only absolute urls. You don't need the relative ones?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I get a syntax error somehow
foreach (Match n in Regex.Matches(source, @(["'])(*?)\1"))
Sergey Alexandrovich Kryukov at 6-Nov-13 12:10pm
Please don't post non-answers as "Solution", it is considered as abuse. You can only get down-votes and abuse reports. Use comments or "Improve question".
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This will find what you have specified:
More exactly it will search for it between matching single or double quotes. Group 2 will contain the url.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,609
1 Sergey Alexandrovich Kryukov 6,240
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100