Start a new topic

Reg Ex to split Name

Hi, 

I'm just setting up an import fr our paypal donations and have run into a slight problem.  Paypal supply supporters name in one field, not split into first name, surname etc.

After looking at the data, Im going to have to make the assumption that most people supply first name and surname  i. e John Smith, so i want to use a Reg Ex to split this field into 2.

Assuming i need 2 expressions, 1 to return everything from the left, up to the first space and one that returns everything from the right until the first space. 

I've been trying to put a reg ex together, and i think it should be something like [^\S+], but its not working properly!

can anyone help?!  Thanks in advance

james


1 person has this question

Hi James,

To get the supporter's name into two fields, you will want to use Excel's Text to Columns. This will split that column into two before you import.

Then you'll add another field to your IOM profile so that the number of columns line up. To add a new field, right click in the field name and choose either "Insert row before" or "Insert row after".

Please let me know if you have any other questions.

Thank you,
Amanda
Omatic Support
You could also try doing this with some virtual columns:

make two columns that call these functions with the original full name column as the seed

_
Public Function ComputedColumn_635102577068458348( _
ByVal oField as ImportOM.API.iField, _
ByVal Cancel As ImportOM.API.iCancel) As String
'This function must return a text value
Dim sReturn As String = ""
Dim aName() As String = Split(oField.Value)

If aName.Length > 0 Then
sReturn = aName(1)
End If
Return sReturn
End Function

_
Public Function ComputedColumn_635102579687970273( _
ByVal oField as ImportOM.API.iField, _
ByVal Cancel As ImportOM.API.iCancel) As String
'This function must return a text value
Dim sReturn As String = ""
Dim aName() As String = Split(oField.Value)

If aName.Length > 1 Then
sReturn = aName(2)
End If
Return sReturn
End Function

DISCLAIMER: I have not tested this code but I think it should work!
[code] <ImportOM.API.VirtualColumn("GetFirstName")> _ Public Function ComputedColumn_635102577068458348( _ ByVal oField as ImportOM.API.iField, _ ByVal Cancel As ImportOM.API.iCancel) As String 'This function must return a text value Dim sReturn As String = "" Dim aName() As String = Split(oField.Value) If aName.Length > 0 Then sReturn = aName(1) End If Return sReturn End Function <ImportOM.API.VirtualColumn("GetLastName")> _ Public Function ComputedColumn_635102579687970273( _ ByVal oField as ImportOM.API.iField, _ ByVal Cancel As ImportOM.API.iCancel) As String 'This function must return a text value Dim sReturn As String = "" Dim aName() As String = Split(oField.Value) If aName.Length > 1 Then sReturn = aName(2) End If Return sReturn End Function [/code]
Login or Signup to post a comment