Find Email Address in String

Category: Regular Expressions

Date: 02-16-2022

Return to Index


 
 
'Compilable Example:  (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg as Dword
 
Function PBMain() As Long
   Dialog New Pixels, 0, "Test Code",300,300,300,200, %WS_OverlappedWindow To hDlg
   Control Add TextBox, hDlg, 200, "please send email to [email protected]", 10,40,280,20
   Control Add TextBox, hDlg, 300, "([a-z0-9._/+-]+)(@[a-z0-9.-]+)", 10,70,280,20
   Control Add Button, hDlg, 100,"Search", 10,10,50,20
   Dialog Show Modal hDlg Call DlgProc
End Function
 
CallBack Function DlgProc() As Long
   Local a$,b$,position&,length&
   If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
      Control Get Text hDlg, 200 To a$
      Control Get Text hDlg, 300 To b$
      REGEXPR b$ IN a$ TO position&, length&
      ? MID$(a$, position&, length&)
   End If
End Function
 
'gbs_01054
'Date: 03-10-2012


created by gbSnippets
http://www.garybeene.com/sw/gbsnippets.htm