We recommend switching to the latest versions of Edge, Firefox, Chrome or Safari. Using Internet Explorer will result in a loss of website functionality.
Our Support systems migrated on Saturday, May 21. We'll automatically forward you to the new location for this content.

Transform Node

Comments

3 comments

  • Avatar
    John Taylor

    It really depends on how complex it needs to be but Python actually supports filtering inline for DIGITS

    configure

    out1.ints = str

     

    Process

    out1 += in1

    str1 = fields.data
    out1.ints = int(filter(str.isdigit, str1))

     

    INPUT

    re456ty
    45jk5k5l
    34e34e
    eerrtt44

     

    OUTPUT

    456
    4555
    3434
    44

    0
    Comment actions Permalink
  • Avatar
    Adrian Williams

    As John's reply shows - there are several ways this can be done. Here is an example using regular expressions.

    ## ConfigureFields Script

    import re

    #Configure all fields from input 'in1' to be mapped 
    #to the corresponding fields on the output 'out1'
    out1 += in1

    out1.DigitsOnly = unicode

    pattern = r'^([a-zA-Z]+)(\d+)$'

    ## ProcessRecords Script

    #Copy all fields from input 'in1' to the corresponding output fields
    #in output 'out1'. Copies the values of the fields that have been setup
    #in the mapping defined in the ConfigureFields property
    out1 += in1

    if fields.Data == Null or fields.Data == "":
      out1.DigitsOnly = Null
    else:
        match = re.match(pattern, fields.Data)
        if match:
            out1.DigitsOnly = match.group(2)
        else:
            out1.DigitsOnly = Null

     

     

     

     

    1
    Comment actions Permalink
  • Avatar
    Tevita Fainga

    thank you...appreciate the help

    0
    Comment actions Permalink

Please sign in to leave a comment.