Community

Reverse split on a field

Please could you tell me what c# script I would use to do a reverse split on a field. I'm attempting to output any text after the last comma within a field that holds multiple address lines delimited by a comma (all residing in 1 field). Thanks
0

Comments

2 comments

  • Avatar
    Scott Chau

    I dont' really have 1 for C# but here is sample code in VBScript

     

    Dim splitted

    'Split value into 2 part using the dash as separation point
    splitted = split(me.Field("FullField").Value, ",", 2)

    'Making sure that there is 2 pieces before grabbing the right value.
    'This is just in case, there is no comma
    if ubound(splitted) > 1 Then
    me.Field("RightField").Value = splitted(1)

    end if

    0
  • Avatar
    Rahul Kapoor

    In c#, you can use below script:

    string path = Context.Field("FullAddress").Text;
    int pos = path.LastIndexOf(",") + 1;
    Context.Field("EndOfAddress").Text = path.Substring(pos, path.Length - pos);

    Regards,
    Rahul Kapoor
    www.linkedin.com/in/rahulkapoor309/

     

    0

Please sign in to leave a comment.