Results 1 to 7 of 7

Thread: [RESOLVED] How to Retrieve Email Address from a String With Same Username

Threaded View

  1. #1

    Thread Starter
    Addicted Member Miklogak's Avatar
    Join Date
    Jan 2013

    Resolved [RESOLVED] How to Retrieve Email Address from a String With Same Username

    I would like to Retrieve All Email Addresses from String, that contains the same Username.

    For Example: The Usernames are in Green Color and Emails in DarkRed below.

    1) 1, 2, Mick, Mick@yahoo.com, 3, 4, 5,
    2) 1, 2, Test, Test@yahoo.com, 3, 4, 5,
    3) 1 ,2, Allen, SomeUser@yahoo.com, 3, 4, 5,

    I need to get the Email Addresses from the first two lines where the USername is same as the Email Addresses. While the 3rd line has a different email.

    So how can I get the Emails of the first two lines and ignore the rest?

    I created a Regex Sample, But I am only able to get the Usernames. Hope I could get some help.

        Private Sub GetDuplicates()
            Dim input As String = txtResults.Text
            Dim pattern As String = ","
            Dim substrings() As String = Regex.Split(input, pattern)
            For Each match As String In substrings
                Dim textToSearch As String = LCase(match)
                If textToSearch.Contains("@") Then RichTextBox1.AppendText(textToSearch & vbCrLf)
                For Each item In ListBoxDuplicatesCheck.Items
                    If isNameInList(item.ToString.ToLower) = True AndAlso Not item.ToString.Contains("@") Then
                        ListBox1.Items.Add(item.Replace(",", ""))
                    End If
        End Sub

    Thank you in advance.

    Last edited by Miklogak; Mar 9th, 2018 at 03:10 PM.

    A huge thanks to all the Great Developers and Helpers on vBForums for helping me and many others! Special thanks to Dunfiddlin, Paul, TechnoGome, , JayInThe813, ident for helping me with my projects througout the years. Incl. those i forgot to mention!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width