Android Question Find Email Address In a string?

Discussion in 'Android Questions' started by aidymp, Mar 18, 2015.

  1. aidymp

    aidymp Active Member Licensed User

    Hi Im struggling a bit with this, basically I want to find an email address in a message body
    i have played with regex but thats not what is needed! As basically I want to search for an Email address in a string not validate one!

    I found this code here and it sounds perfect but i cant convert it

    Public Function FindEMailAddressesInStr(ByVal StringWithEmails As StringAs List(Of String)
    Dim emailList As New List(Of String)
    Dim RegExMatch As Text.RegularExpressions.MatchCollection = _
            System.Text.RegularExpressions.Regex.Matches(StringWithEmails, _

    For i As Integer = 0 To RegExMatch.Count - 1
    If emailList.Contains(RegExMatch(i).Value) = False Then
    End If

    Return emailList
    End Function
    Any Help

  2. NJDude

    NJDude Expert Licensed User

    Try THIS

    Also, search for Regex.Matcher.
    thedesolatesoul and aidymp like this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    Sub Activity_Create(FirstTime As Boolean)
    Log(FindEmails($", lkjlk jsdf lksdjf"$
    End Sub

    Sub FindEmails(str As StringAs List
    Dim m As Matcher = Regex.Matcher("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", str)
    Dim res As List
    Do While m.Find
    Return res
    End Sub
  4. aidymp

    aidymp Active Member Licensed User

    Thanks but from what i read that just validates if a sting contains a correctly formatted email address? not actually finds an email address in a large text file? But
    Thanks for your very fast response! ;)
  5. aidymp

    aidymp Active Member Licensed User

    Thanks once again Erel, Amazing! , Amazing! , Amazing! ;)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice