GSAK (Geocaching Swiss Army Knife)
Contents - Index

RegExPos (function)

RegExPos(sExpression, sData, nNumber) : Number

This function allows you to find the offset position (base 1) of the matched instance of your regular expression. It is similar to the at() function but is more powerful as you can use a regular expression for your match and you can also specify the matching instance number. If there is no match for that instance the function will return 0.

sExpression - The regular expression to match
sData - The data string to search for sExpression
sNumber - The found instance

Examples:
 

#find offset of second match of "cat"
$pos = regexpos("cat","my cat is a very fat cat!",2)
msgok msg=$pos

 
 
 

#find offset of first match of "cat"
$pos = regexpos("cat","my cat is a very fat cat!",1)
msgok msg=$pos

 
 
 
Alpha List         Category List
Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact