GetAllRegexMatches

Top  Previous  Next

Sub GetAllRegexMatches($source As String, $regex As String) As String

 

Searches in $source for all occurrences of $regex. $regex is a Regular Expression.

 

GetAllRegexMatches is case-insensitive. Each match is listed in a new line, separated with a carriage-return/line-feed. If $regex is not found, GetAllRegexMatches returns an empty string.

 

Parameters

 

$source ... String expression sought.
$regex ... Regular expression being searched.

 

Example:

Dim $s, $s2

 

$s = "this number 12 or number 1003 or a date"

$s2 = GetAllRegexMatches($s, "number \d+")

'returns $s2 = "number 12"#13#10"number 1003"

 

The extracted lines can be sorted with the function SortStringLines