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.  Regular Expression

    Employee
    Posted 09-04-2011 03:37

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

    Originally posted by: xathras

    Hi,

    IS there any functionality to perform some regular expression, if so what and how do I use it.

    As an example.

    I have a delimiter file with a number of email addresses and I want to perform some validation on them.

    e.g. check bob@bob.com is valid. Whereas invalid formats are highlighted as rejected.

    e.g. bob.@bob.com, .bob@bob.com, bob@..bob.com

    Thanks


  • 2.  RE: Regular Expression

    Employee
    Posted 09-05-2011 02:44

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

    Originally posted by: Tim Meagher

    Hi,

    The following BRAINscript regular expression functions are available:

    • regexIsMatch
    • regexIsMatchI
    • regexMatch
    • regexMatchI
    • regexSubstitute
    • regexSubstituteI
    These are all documented in the BRAINscript Language help available within BRE. To view the help for these functions, simply go to Help->BRAINscript Help within BRE.


    The "Split By Pattern" node is preconfigured to take an input and split the records into two outputs based on whether the specified input Field(s) match the specified regular expression.

    I think the attached node has the functionality you want.
    I've basically used the regex (with a couple of modifications to not allow leading "." characters and to fit in with the required escaping syntax in BRAINscript) defined here: http://www.regular-expressions.info/email.html

    There are two examples of usage in the attached graph.
    The first (top) node uses a Filter node.
    Within the filter node, you can use the RegexIsMatchI to perform a case insensitive regex match, so the regex doesn't need to have all lowercase & uppercase combinations.
    In addition, since this is a filter node, you can perform other operations within this node if desired (such as renaming output fields, only outputting certain fields etc).

    The second (bottom) node uses the Split By Pattern node.
    Because the Split By Pattern node is pre-configured, no BRAINscript is required, only the regex & the field to match against.
    In this case, however, the regex is treated as case sensitive, therefore the regex pattern must contain all combinations of upper and lower case characters. Also, since the node is used purely for splitting, no additional operations (such as renaming output fields, only outputting certain fields etc) cannot be performed.

    Hope this helps.

    Tim.
    Attachments:
    ValidateEmails.brg


  • 3.  RE: Regular Expression

    Employee
    Posted 09-05-2011 11:40

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

    Originally posted by: xathras

    Thanks Tim. Just what I need.

    I tried the complex way this morning with Python and oh well, what a pain!!!