regexFindStr#

swordfish.function.regexFindStr()#

Different from regexFind which returns the positions of the matched strings, regexFindStr searches from the offset position and returns the matched substring.

  • When str is a scalar:

    • If onlyFirst is set to true, return the first substring that matches pattern. Otherwise return an empty string.

    • If onlyFirst is set to false, return a STRING vector containing all non-overlapping matches. Otherwise return an empty STRING vector.

  • When str is a vector:

    • If onlyFirst is set to true, return the first substring that matches pattern for each string of str. Otherwise return a STRING vector of the same length as str, with all elements being empty strings.

    • If onlyFirst is set to false, return a tuple containing all non-overlapping matches for each string of str. Otherwise return an tuple of the same length as str, with all elements being empty STRING vectors.

Parameters:
  • str (Constant) – A STRING scalar or vector, indicating the target string to be scanned.

  • pattern (Constant) – A string indicating the string pattern with regular expression. It can contain literals and metacharacters.

  • onlyFirst (Constant, optional) –

    A Boolean value indicating whether to return only the first substring that matches pattern for each string.

    • true (default): Return the first match.

    • false: Return all non-overlapping matches.

  • offset (Constant, optional) – A non-negative integer indicating the starting position for the search in str. The default value is 0, which is the first position of str.