string_pos

Declaration

string_pos (text, sub: STRING; start: INTEGER): INTEGER

Description

Finds the first occurrence of sub in text starting with character start. If sub is not found, the function returns 0. If it is found, it returns a 1-based offset from the start of the string.

See Also

substring
string_length
string functions

Example

script cut_strings is
  str := 'test'
  pos := string_pos (str, 't', 1)
    -- pos = 1
  if (pos > 0) then
    s := substring (str, pos, string_length (str) - pos)
      -- s == 'est'
    pos := string_pos (s, 't')
      -- pos = 3
  end
end