LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Seperate a section from a string value and replace altered value

    Employee
    Posted 02-25-2013 09:18

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: khopkins

    Hello
    I am trying to use brain script to separate out a string value in a field so that i can adjust a specified section and adjust the data within that section.
    The issue i am having is that whilst the values inside the string are separated by "_" the individual values are not always the same length so i can not use a substring.

    for example the string CDR_TTB_15_LLU_20130101_20130101_000006_1100147608 needs to have the 7th section of the string padded with extra zero`s.

    Does anyone have any examples of how this can be accomplished please?

    Keith


  • 2.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 02-25-2013 10:01

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    There are a lot of such situations where the SPLIT operator comes in very handy.

    s=split(Text,"_")
    emit Text,Fixed=s[0]+"_"+s[1]+"_"+s[2]+"_"+s[3]+"_"+s[4]+"_"+s[5]+"_"+pad(s[6],6)+"_"+s[7]


  • 3.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 02-26-2013 01:42

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: khopkins

    Thanks Stony that's perfect i was looking at the split function but i wasnt aware i could treat it an an array and use it that way


  • 4.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 05-08-2013 02:34

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Wizardous

    Hi

    Similar to this issue I need to get value or values from a field between characters ">" and "<". As they are not same, one split function won't work for me. On the other hand I can not give specific numbers of "<" and ">" occurance on the field, as it changes by row (may be none "<" and ">", or more than 5, or just 1 etc.). So I need to do more than 1 split with while loop I think?

    My question here is;

    Is there a function that does remove between "<" and ">" or get between ">" and "<"?

    Or do you have a suggestion? I would be greatful.

    Thank you,

    Kind regards,

    �zg�n


  • 5.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 05-08-2013 02:47

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rboccuzzi

    There are a number of ways to do this, including just a couple of splits (you wouldn't need a while loop if there is always just one > and one <, just do them consecutively), or doing BRAINscript using regex functions. I have attached a way that seems the easiest and most extensible for your needs, using the Extract Pattern node. This seems to handle NULLs, and multiple values pretty well; you can change the "," to something else if you like for separating multiple values; it's an option in the Extract Pattern node.

    Cheers
    Rich
    Attachments:
    Extract Pattern Example.brg


  • 6.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 05-08-2013 03:53

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: khopkins

    Hi Rich,

    Is there any chance of having a solution to this in 4.5.2 version of LAE as i would be interested in this solution for a different process and your graph will not open correctly in our version?

    Regards,

    Keith


  • 7.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 05-08-2013 04:01

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rboccuzzi

    Sure Keith, here you go, this should work.

    Cheers
    Rich
    Attachments:
    Extract Pattern Example.brg


  • 8.  RE: Seperate a section from a string value and replace altered value

    Employee
    Posted 05-08-2013 04:06

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Wizardous

    Thank you Rich. This works great for me.

    Regards,

    �zg�n