Click here to Skip to main content
15,921,062 members
Home / Discussions / C#
   

C#

 
AnswerRe: Weird behaviour with Async method call Pin
Guffa15-Nov-08 6:01
Guffa15-Nov-08 6:01 
GeneralRe: Weird behaviour with Async method call Pin
kensai16-Nov-08 1:01
kensai16-Nov-08 1:01 
Questionforms or usercontrols or panels or what ? Pin
jogisarge15-Nov-08 0:07
jogisarge15-Nov-08 0:07 
AnswerRe: forms or usercontrols or panels or what ? Pin
zafersavas15-Nov-08 12:58
zafersavas15-Nov-08 12:58 
GeneralRe: forms or usercontrols or panels or what ? Pin
jogisarge15-Nov-08 23:35
jogisarge15-Nov-08 23:35 
QuestionForeach URL in file... Pin
jas0n2314-Nov-08 23:14
jas0n2314-Nov-08 23:14 
AnswerRe: Foreach URL in file... Pin
Wendelius14-Nov-08 23:26
mentorWendelius14-Nov-08 23:26 
GeneralRe: Foreach URL in file... Pin
jas0n2315-Nov-08 0:48
jas0n2315-Nov-08 0:48 
Thanks for your help I had a look at the MSDN link you gave me and here's what I ended up using:


private void ReadFileLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    StreamReader ReadFile = new StreamReader("C:\\Users\\Jase\\Desktop\\File.txt");
    textBox1.Text = ReadFile.ReadToEnd();
    ReadFile.Close();
}

private void PerformSearchLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    // Define a regular expression for repeated words.
    Regex rx = new Regex(@"\b(?<word>\w+)\s+(\k<word>)\b",
      RegexOptions.Compiled | RegexOptions.IgnoreCase);

    // Define a test string.
    string text = textBox1.Text;

    // Find matches.
    MatchCollection matches = rx.Matches(text);

    // write the number of matches found.
    Streamwriter jt = new StreamWriter(C:\\Users\\Jase\\Desktop\\NEW_File.txt");
    jt.Write("{0} matches found in:\n   {1}" + matches.Count + text);
    jt.Close();

    // Report on each match.
    foreach (Match match in matches)
    {
        GroupCollection groups = match.Groups;
        textBox1.Text = ("'{0}' repeated at positions {1} and {2}" + groups["word"].Value + groups[0].Index + groups[1].Index);
    }

}



However, it doesn't seem to work. At all. It never finds anything. How would I go about telling Regex to search for any URL, no matter what URL it is inside a text file? This has got me stumped.

Best Regards,
j.t.

j.t.

GeneralRe: Foreach URL in file... Pin
Wendelius15-Nov-08 1:29
mentorWendelius15-Nov-08 1:29 
GeneralRe: Foreach URL in file... Pin
jas0n2315-Nov-08 1:33
jas0n2315-Nov-08 1:33 
QuestionHow to send Left/Right shift keys? Pin
MRafeie14-Nov-08 22:58
MRafeie14-Nov-08 22:58 
Questionadd-on Pin
AmbitiousBeginner14-Nov-08 22:51
AmbitiousBeginner14-Nov-08 22:51 
QuestionImage retrieving [modified] Pin
B8714-Nov-08 21:32
B8714-Nov-08 21:32 
AnswerRe: Image retrieving Pin
Wendelius14-Nov-08 22:59
mentorWendelius14-Nov-08 22:59 
GeneralRe: Image retrieving Pin
nelsonpaixao15-Nov-08 5:06
nelsonpaixao15-Nov-08 5:06 
QuestionRequiring registration code Pin
Edward Hoad14-Nov-08 18:50
Edward Hoad14-Nov-08 18:50 
AnswerRe: Requiring registration code Pin
MavKilla15-Nov-08 1:34
MavKilla15-Nov-08 1:34 
QuestionA question about s singleton applicaiton? Pin
Jason_Shen14-Nov-08 15:14
Jason_Shen14-Nov-08 15:14 
AnswerRe: A question about s singleton applicaiton? Pin
Giorgi Dalakishvili15-Nov-08 0:35
mentorGiorgi Dalakishvili15-Nov-08 0:35 
AnswerRe: A question about s singleton applicaiton? Pin
Wendelius15-Nov-08 0:40
mentorWendelius15-Nov-08 0:40 
GeneralRe: A question about s singleton applicaiton? Pin
Jason_Shen15-Nov-08 3:48
Jason_Shen15-Nov-08 3:48 
GeneralRe: A question about s singleton applicaiton? Pin
Wendelius15-Nov-08 4:13
mentorWendelius15-Nov-08 4:13 
AnswerRe: A question about s singleton applicaiton? Pin
Jason_Shen17-Nov-08 3:27
Jason_Shen17-Nov-08 3:27 
Questionproblem in custom paging.. Pin
kamalesh574314-Nov-08 15:11
kamalesh574314-Nov-08 15:11 
AnswerRe: problem in custom paging.. Pin
Guffa14-Nov-08 18:06
Guffa14-Nov-08 18:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.