$poscs » History » Version 2
Per Amundsen, 02/23/2023 07:13 PM
| 1 | 1 | Per Amundsen | _Added in 1.8.10_ |
|---|---|---|---|
| 2 | |||
| 3 | *$poscs(string,substring,N)* |
||
| 4 | |||
| 5 | Returns a number indicating the position of the Nth occurrence of string in text. |
||
| 6 | |||
| 7 | _[[$poscs]] is case-sensitive, see [[$pos]] for case-insensitive version._ |
||
| 8 | |||
| 9 | *Parameters* |
||
| 10 | |||
| 11 | 2 | Per Amundsen | table(ktable). |
| 12 | |*Parameter*|*Description*| |
||
| 13 | | string | String to search. | |
||
| 14 | | substring | Substringto search. | |
||
| 15 | | N | If N = 0, total number of matches, otherwise the Nth match. | |
||
| 16 | 1 | Per Amundsen | |
| 17 | *Example* |
||
| 18 | |||
| 19 | <pre> |
||
| 20 | ; Print number of matches for the substring 'E'. |
||
| 21 | //echo -ag $pos(heEllo theEreE,e,1) |
||
| 22 | |||
| 23 | ; Print the position of the second match using substring 'E'. |
||
| 24 | //echo -ag $pos(hEello thEereE,E,2) |
||
| 25 | </pre> |