rpos(string,substring)
Description
Same as pos() but substring may be a regular expression gives the position of substring in the search string position starts with 1 at the left end returns 0 if no match found.
Example
rpos(ITT,'\([A-Z]:\\\.+?\)')
- returns a position of path string in the item text, if path is recorded as something like (D:\MyDocuments\Ecco)
- Could be use, for example, for extracting a file name from an item created by Tools|Launch|Add File as Item... command,
trim(left(ITT,rpos(ITT,'\([A-Z]:\\\.+?\)')-1))
- from item text "rules.eco (D:\MyDocuments\Ecco)" the function returns "rules.eco"
- rpos(ITT,'\([A-Z]:\\\.+?\)') returns a position of (Path) in the item text
- -1 to exclude left bracket of (Path) from the selection
- left() returns a part of the item text before the given position
- trim() deletes leading and tracing spaces
Related Rules
pos()