findstring
You can use the [findstring] global tag to find the location of a sub-string within a given source string.
[findstring source=...&find=...&matchcase=...&reverse=...&startat=...]
Parameters
Parameter | Description |
---|---|
source | (required) The character string to search. |
find | (required) The character string to find. |
matchcase | (optional) T/F, default 'F', when set to 'T', the search will be case sensitive. |
reverse | (optional) T/F, default 'F', when set to 'T', the search is performed starting from the end of the 'source' string. |
startat | (optional) Sets the start position, in the 'source' string, from which to start the search. If not specified, the search will start from the beginning of the 'source' string. If the 'reverse' parameter is set to 'T', the 'startat' position is relative to the end of the 'source' string. |
[text]varSTRING=WebDNA is a powerful, easy to learn, scripting language.[/text]
[text]varFOUNDAT=[findstring source=[varSTRING]&find=powerful][/text]
[showif [varFOUNDAT]>0]
Found 'powerful' in source string at character position [varFOUNDAT]
[/showif]
[hideif [varFOUNDAT]>0]
String 'powerful' not found.
[/hideif]
Results:
Found 'powerful' in source string at character position 13
(starting from character #[varFOUNDAT] from the start of the text)