RegexRegex.Group()Returns a capture group. Group(0) is the full capture string. Arguments
ReturnTypeString Examplelet regex(Regex) let b(Boolean) let ss(String) let i(Integer) regex = Regex("+(/d{2})/s(/d{3})-(/d{3})-(/d{4})") b = regex -> Search("Tel : +33 111-777-9999") i= 0 for i while i< regex->GroupCount() { Notify("Group # : #", i, regex ->Group(i)) } //The result is: Group 0: +33 111-777-9999 Group 1: 33 Group 2: 111 Group 3: 777 Group 4: 9999 Regex.GroupCount()Returns the number of matched groups. It includes the entire regular expression. Note that the groups are regular expressions that correspond to the string in parenthesis in the string that defines the regular expression. SignatureRegex.GroupCount() : Integer ReturnTypeInteger Examplelet regex(Regex) let i(Integer) regex = Regex("+(/d{2})/s(/d{3})-(/d{3})-(/d{4})") i= regex->GroupCount() // i == 5 because we have 4 groups plus one for the entire regular expression. Regex.Match() Returns Arguments
ReturnTypeBoolean Examplelet regex(Regex) let b(Boolean) regex = Regex("+(/d{2})/s(/d{3})-(/d{3})-(/d{4})") //Test Match b = regex -> Match("Tel : +33 111-777-9999") // b == False b = regex -> Match("+33 111-777-9999") //b == True Regex.Replace()Allows to substitute the part of the input text matching a regular expression by another text. SignatureRegex.Replace(stringToReplace : String, stringToSearch : String, nbMaxSubstitutions : Integer) : String Arguments
ReturnTypeString Examplelet regex(Regex) let b(Boolean) let reBackRef(String) let ss(String) regex = Regex("+(/d{2})/s(/d{3})-(/d{3})-(/d{4})") reBackRef = "\\2::\\3::\\4" ss = regex->Replace(reBackRef,"+33 111-777-9999",-1) // ss == “111::777::9999” Regex.Search() Returns Arguments
ReturnTypeBoolean Examplelet regex(Regex) let b(Boolean) regex = Regex("+(/d{2})/s(/d{3})-(/d{3})-(/d{4})") //Test Search b = regex -> Search("Tel : +33 111-777-9999") //b == True b = regex -> Search("Tel : +33 0111-777-9999") //b == False |