call a function inside a reg ex

Results 1 to 2 of 2

Thread: call a function inside a reg ex

  1. #1
    Join Date
    Dec 1969

    Default call a function inside a reg ex

    hi,<BR>I&#039;m trying to call a funcion from inside a regular expression withour success, I post some explicative code:<BR>-------------------------------<BR>function miaFunzione1 (parametro1)<BR> [.........]<BR>end function<BR><BR><BR><BR>function miaFunzione2 (parametro2)<BR><BR> regEx.Pattern = "....."<BR> miaStringa= regEx.Replace(parametro2, miaFunzione1("$2") )<BR> miaFunzione2= miaStringa<BR><BR>end function<BR>---------------------------<BR><BR>$2 is the reg ex parameter I want to pass to miaFunzione1, but this way I pass "$2" - as a string, not the value!<BR><BR>any suggestion?<BR><BR>thank you!! <BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: call a function inside a reg ex

    Get a matches collection by using the Execute method. Then iterate through it to get each match object, then get the submatch ($1, $2,...) from each match object&#039;s SubMatches collection. Pass this submatch to your other function, then use the Replace function to do the substitution (replacing the next matched string with the modified submatch).<BR><BR>Hope it makes sense...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts