#Define cSTART '^'
#Define cEND '$'
#Define cDATE '\d{1,}\/\d{1,}\/\d{2,}'
#Define cNUMBER '\d+'
#Define cSPACES '\s+'
#Define cOPTIONALSPACES '\s*'
#Define cUPPERALPHANUMERICSLASHES '[A-Z0-9\/]+'
#Define cNAME '[A-Za-z]+\.[A-Z]'
#Define cCALLSIGN cUPPERALPHANUMERICSLASHES+'|'+cNAME
#Define cAREA '[A-Z0-9\/]{4}'
#Define cANYTHING '.*'
TEXT To lcMail NoShow
Dear David,
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis rhoncus ante eu pellentesque rutrum. Nam sit amet scelerisque
arcu. Maecenas suscipit tincidunt dui id aliquam. Aenean lobortis ullamcorper euismod. Suspendisse at sapien rhoncus,
ultrices lacus imperdiet, porttitor lectus. Maecenas ut urna elementum, ullamcorper magna vitae, fermentum tortor. Quisque
dui mi, lacinia in mollis sed, imperdiet a leo. In in laoreet ante. Aliquam tortor ligula, efficitur ut erat quis, imperdiet
rutrum turpis. Nunc ultrices euismod nibh, in faucibus mauris. Nunc rutrum mauris diam, eget tempus lorem suscipit non. In
malesuada risus vel erat fringilla, sed aliquam risus sodales.
01/01/2020 52931 M9TEK SP83
05/01/2020 52932 GW9TIP TL14 Any additional information here
06/06/2020 62014 MM9ATK
13/13/0823 12345 Trump.D SP83 Bulls**t
13/13/0823 12345 Trump.D F*** ***s
05/06/2020 345789 .................
ENDTEXT
m.RegExp = Createobject("VBScript.RegExp")
* extract Date, Number, Callsign, Area
For m.LineIndex = 1 To Alines(paLines, m.lcMail)
* PASS 1, detecting DATE and NUMBER
m.RegExp.Pattern = cSTART + cOPTIONALSPACES + '('+cDATE + ')' + cSPACES + '(' + cNUMBER + ')' + cANYTHING + cEND
m.Matches = m.RegExp.Execute(m.paLines(m.LineIndex))
If m.Matches.Count = 1
m.Match = m.Matches.Item(0)
If m.Match.Submatches.Count = 2
lcDate = m.Match.Submatches.Item(0)
* You could veryfy valid date here easier than in regexp by trying to cast to date.
lcNumber = m.Match.Submatches.Item(1)
Endif
* remove Date and number for PASS 2 matching
m.paLines(m.LineIndex) = Strtran(m.paLines(m.LineIndex),lcDate,'',1,1,2)
m.paLines(m.LineIndex) = Strtran(m.paLines(m.LineIndex),lcNumber,'',1,1,2)
* PASS 2, CALLSIGN and AREA
m.RegExp.Pattern = cSTART + cOPTIONALSPACES + '(' + cCALLSIGN + ')' + cSPACES + '(' + cAREA + '|' + cSPACES+ ')' + cANYTHING + cEND
m.Matches = m.RegExp.Execute(m.paLines(m.LineIndex))
If m.Matches.Count = 1
m.Match = m.Matches.Item(0)
If m.Match.Submatches.Count = 2
lcCallsign = m.Match.Submatches.Item(0)
lcArea = m.Match.Submatches.Item(1)
? 'Date:',lcDate, 'Number:',lcNumber,'Callsign:', lcCallsign, 'Area:',lcArea
* Here you have a full record and can insert it.
Insert Into DataStore ; && (date, number,. callsigm, area, note)
Values (Ctod(lcDate), ;
VAL(lcNumber), ;
lcCasllsign, ;
IIF(lcArea == 'N/A', '', Nvl(lcArea, '')), ;
'')
Endif
Else
* You might do something with Date and Number here anyway.
* For example, store it with the rest of the information in m.paLines(m.LineIndex) for a Memo for later manual or extended regex parsing
? 'Only date and number:', lcDate, lcNumber
Endif
Endif
Endfor