Regular Expression Functions

Overview

This Plug-in exposes Java Regular Expression string manipulation capabilities as Appian Functions. Very useful for validation rules and data manipulation on interactive SAIL forms.  

Key Features & Functionality

Datatypes provided:

  • RegexMatch - has a string field representing the string found, a starting index for the string in the haystack and an ending index for the string in the haystack

Regex Flags supported:

  • i - case insensitive
  • g - find all matches
  • m - multiline search
  • s - treats the entire string as a single line
  • u - unicode aware search
  • x - ignores comments starting with '#' and white spaces
  • d - enables unix line mode

Functions provided:

  • regexSearch - Searches for the selected pattern with the specified regex options and returns a list of RegexMatch Datatypes, accepts all regex flags.
  • regexArraySearchIndexOfFirstMatch - Searches an array for a match and returns the first index of match found
  • regexMatch - Indicates whether the regular expression finds a match in the input string, accepts all regex flags.
  • regexInsertMatchMarkers - Finds the match or matches and surrounds them with starting and ending markers, accepts all regex flags.
  • regexFirstMatch - Returns the first match of the regular expression within the input string, accepts all regex flags except 'g'.
  • regexAllMatches - Returns all matches of the regular expression within the input string, accepts all regex flags.
  • regexReplaceAll - Replaces all matches of the regular expression within the input string
Anonymous
Parents
  • Hey Chris,

    I'm trying to use regexReplaceAll() to escape the pattern string to make it safe for use with regexSearch().

    Unfortunately, I can't seem to make regexReplaceAll() function work.  I rather not use sustitute() function for each and every special characters in regular expression.

    In function regexReplaceAll(), the replacement string doesn't seem to support the regular expression substitution syntax.  I need to be able dynamically escape special characters and I can't seem to be able to dynamically escape characters I'm escaping.

    Let me know if there is a way to get it to work in using your library.  I'm trying to escape the usual suspects:

    ., +, *, ?, ^, $, (, ), [, ], {, }, |, \ (not including commas).

    Also, I remember using the regular expression plugin twice in the last decade and I remember that version was more like the industry standard regular expression function behavior, similar to one implemented in Java.  Am I wrong?  Also, could it be possible to be more of a transparent call to how the regular expression works in Java?

    Thanks.

  • I got it to work.  Here's an excerpt of my code in case anybody else is interested in escaping their regular expression pattern using regexReplaceAll() function.

    local!escapedPatternList: a!forEach(
        items: local!patternList,
        expression: fn!regexreplaceall(
          "([+-.\*?^$\(\)\[\]\{\}\|\\])",
          fv!item,
          "\\$1"
        )
    )

Comment
  • I got it to work.  Here's an excerpt of my code in case anybody else is interested in escaping their regular expression pattern using regexReplaceAll() function.

    local!escapedPatternList: a!forEach(
        items: local!patternList,
        expression: fn!regexreplaceall(
          "([+-.\*?^$\(\)\[\]\{\}\|\\])",
          fv!item,
          "\\$1"
        )
    )

Children
No Data