Ian Fila

Ian Fila

  • NA
  • 1
  • 0

Convert vbscript to visual C# for use in SSIS

May 15 2009 8:40 AM

The input files are text resumes and i am looking to output the text resume in one column and extract all the emails in another column.

Thanks 

 

 

Dim regEx, Matches, emails

Set regEx = New RegExp

regEx.Global = True

regEx.IgnoreCase = True

'----------------- OnRecord -----------------

Function OnRecord

Dim em

em = GetEmail(DictIn.Field_1.value)

If Len(em) Then

If Len(emails) Then emails = emails & "; "

emails = emails & em

End If

This.SkipRecord

DictOut.Emails.value = DictIn.Field_1.value

End Function

'----------------- OnFinishProcess -----------------

Function OnFinishProcess

Dim i

DictOut.SetFieldValue 1, emails

This.AppendRecord

End Function

'-----------------

Function GetEmail(s)

Dim i, p, ms, m

p = InStr(s, "@")

If p > 0 Then

regEx.Pattern = "\w(\w|\.)*@(\w|\.)*\w"

Set ms = regEx.Execute(s)

If ms.count > 0 Then

For Each m in ms

If Not Target.IsEmpty(c) Then c = c & ";"

c = c & m.value

Next

GetEmail = c

End If

End If

End Function