How Test which regex pattern found

Hi everyone
Like Kem as sugest me… I try to simplify my regex find & replace
I removed all my over redundancy and finish to that

for o =1 to lbpreview2.ListCount-1 for m = 1 to lbpreview2.ColumnCount-1 //unite ang re.searchPattern = "^(\\d)$" re.replacementPattern = "\\$\\1" contentk = str(lbpreview2.Cell(o,m)).Trim lbpreview2.Cell(o,m) = re.Replace( contentk ) Next Next
thanks to kem
For simplify another step how can i test which pattern found

re.searchPattern = "^(\\d)$" // found unit re.searchPattern = "^(\\d)(\\d)$" // found decade re.searchPattern = "^(\\d)(\\d)(\\d)$" // found hundred re.searchPattern = "^(\\d)(\\d)(\\d)(\\d)$" //found thousand
I swear, i try to make it by myself but dont know what to search
I know this is bad… thats why i need help

if contentk = re.searchPattern "^(\\d)$" then  re.replacementPattern = "\\$\\1"


What would the replacement patterns be for each search pattern?

For the english
unit = “\$\1”
decade “\$\1\2”
hundred “\$\1\2\3”
thousand “\$\1\2\3”

and the french
unit = “\1@\$”
decade “\1\2@\$”
hundred “\1\2\3@\$”
thousand “\1@\2\3\4@\$”

The @ is swap to thin space in pagelayout software

The English one is easy since there is no symbol to insert between the numbers:

SearchPattern = "^(\\d+)$" // Save for either
ReplacementPattern = "\\$$1"

For French, you can extract the digits found, then manipulate them in Xojo code:

    dim match as RegExMatch = re.Search( s )
    if match <> nil then
      dim digits() as string = match.SubExpressionString( 1 ).Split( "" )
      dim lastIndex as Integer = digits.Ubound - 2
      for i as Integer = lastIndex downto 1 step 3
        digits.Insert( i, "@" )
      next i
      s = Join( digits, "" ) + "@$"
    end if

I tested this and it works like a charm.