Results 1 to 4 of 4

Thread: Using StrFindI syntax - Unwanted matches

  1. #1

    Default Using StrFindI syntax - Unwanted matches

    Hi Smart people

    I have a task involving matching the letters GM in a larger string of position title & having trouble wrapping my head around the syntax. This is my first coding language so apologies in advance if I need to ask for clarification.

    So far I'm using the following code (below) in my filter nodes to filter out matches such as "management" where GM appears mid string. This works ok, until the string finishes with the letters GM, which results in being also filtered with the undesirable records.

    I've been trying to figure out whether there's syntax for identifying records which finish with GM, like a wildcard that indicates the string stops after GM.

    I've also wondered whether I could search only the last 3 characters of the string for " GM" to prevent any false hits on records such as GMD, but haven't been able to understand the syntax to do so yet.

    Code:
    positionTitle.strFindI("GM ") == -1
    Apologies if the question is overly basic, I'm still learning!

  2. #2
    Lavastorm Employee stonysmith's Avatar
    Join Date
    Nov 2006
    Location
    Grapevine Tx
    Posts
    799

    Default

    One easy way to search the righthand 3 characters is to use the right() function.

    Code:
    positionTitle.right(3).strFindI("GM ") == -1
    For a more complicated, more capable search function, you could use Regular Expressions, but those can get very confusing fast.

    This will find any of the letters GM
    Code:
    positionTitle.regexIsMatchI(".*GM*")
    Where this will find it only on the end of the string
    Code:
    positionTitle.regexIsMatchI(".*GM")
    Regex expressions can get extremely sophisticated, but they're very terse, and therefore can be quite tough to read.
    For a full set of Regex documentation, consult www.pcre.org

  3. #3
    Lavastorm Employee gmullin's Avatar
    Join Date
    May 2014
    Location
    Chicago
    Posts
    185

    Default

    Just to add one more suggestion to Stony's regex examples this:

    Code:
    positionTitle.regexIsMatchI(" GM")
    Should work for what you need. Basically anywhere with " GM" in the string (GM must be preceded by a white space) regardless of upper or lower case. If you want to look for only upper case GM then use regexIsMatch().

  4. #4

    Default

    Thank you very much!

    I had been trying to figure out the syntax for left and right, but I had been trying to nest it with parentheses as you would in excel.

    RegismatchI is new, I'll have something new to learn about.

    I appreciate the help, thanks folks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •