Problem with regsub in TCL script

Version 1
    This document was generated from CDN thread

    Created by: Reinhard Schloeglhofer on 02-08-2010 08:00:26 AM
    Hello,
     
    I have a strange behaviour with the regsub command:
     
    There are the following variable settings:
    lookupSEARCHPATTERN is set to {200([0-9]+)}
    ani is set to 20025
    lookupREPLACEPATTERN is set to {999\1}
     
    When i call the regsub command
    regsub -all $lookupSEARCHPATTERN $ani $lookupREPLACEPATTERN anicorr
    in the tclsh, it correctly returns 99925 to variable anicorr.
     
    Doing the same during an incoming call, the error message
     
    Aug 02 09:45:41 172.24.10.66 23368: Aug  2 07:45:40.484: //1472//AFW_:/AFW_FSM_Drive: Tcl_Eval to drive FSM inside Tcl modulespace. code=1 code=ERROR
    Aug 02 09:45:41 172.24.10.66 23369: Aug  2 07:45:40.484: TCL script failure
    Aug 02 09:45:41 172.24.10.66 23370:     Result:
    Aug 02 09:45:41 172.24.10.66 23371:              couldn't compile regular expression pattern: quantifier operand invalid
    Aug 02 09:45:41 172.24.10.66 23372: Aug  2 07:45:40.484:     TCL script failure errorInfo:
    Aug 02 09:45:41 172.24.10.66 23373:             couldn't compile regular expression pattern: quantifier operand invalid
    Aug 02 09:45:41 172.24.10.66 23374:     while executing
    Aug 02 09:45:41 172.24.10.66 23375: "regsub  $lookupSEARCHPATTERN $ani $lookupREPLACEPATTERN anicorr "
    Aug 02 09:45:41 172.24.10.66 23376:     (procedure "act_Setup" line 1250)
    Aug 02 09:45:41 172.24.10.66 23377:     invoked from within
    Aug 02 09:45:41 172.24.10.66 23378: "act_Setup"
     
    is returned and the call is interrupted.
     
    I have dumped the variable content and it is correct (output is "regsub -all {200([0-9]+)} 20025 {999\1} anicorr")
     
    When i call the statement
    regsub -all {200([0-9]+)} 20025 {999\1} anicorr
      during the call (without using variables) it is ok
     
    Can someone please help me ?
     
    Thanks and kind regards
    Reinhard

    Subject: RE: Problem with regsub in TCL script
    Replied by: Reinhard Schloeglhofer on 02-08-2010 10:58:44 AM
    Hi Raghavendra,
     
    Thank you for your response.
    This code is also working in my application. The difference is, that i set the values in the application configuration:
    application
    service xxx
    param lookupSEARCHPATTERN {200([0-9]+)}
    param lookupREPLACEPATTERN {999\1}
     
    I am sure, that the variables are correct, because i made a puts before:
    puts "($ani,$dnis) regsub -all $lookupSEARCHPATTERN $ani $lookupREPLACEPATTERN anicorr"
    regsub -all $lookupSEARCHPATTERN $ani $lookupREPLACEPATTERN anicorr
     
    The puts command printed out
    (20025,1011) regsub -all {200([0-9]+)} 20025 {999\1} anicorr

     
     
    Thanks, kind regards
    Reinhard
     

    Subject: RE: Problem with regsub in TCL script
    Replied by: Reinhard Schloeglhofer on 02-08-2010 12:11:49 PM
    Hi Raghavendra,
     
    Thank you for your help ! I don't understand why, but now it works.
     
    kind regards
    Reinhard
     

    Subject: RE: Problem with regsub in TCL script
    Replied by: Raghavendra Gutty Veeranagappa on 02-08-2010 10:39:33 AM
    Hi Reinhard,
     
    i have tested following code which returns 99925 , i am not getting error

    proc act_Setup { } {
    set lookupSEARCHPATTERN {200([0-9]+)}
    set ani 20025
    set lookupREPLACEPATTERN {999\1}
    regsub -all $lookupSEARCHPATTERN $ani $lookupREPLACEPATTERN anicorr
    puts "anicorr:$anicorr"
    }
     
    Please post your code so that we can test and let you know
     
    Thanks
    Raghavendra

    Subject: RE: Problem with regsub in TCL script
    Replied by: Raghavendra Gutty Veeranagappa on 02-08-2010 11:37:13 AM
    Hi Reinhard,
     
    Please run following commands and test it will work
     
    application
    service xxx
    param lookupSEARCHPATTERN 200([0-9]+)
    param lookupREPLACEPATTERN 999\1

    Thanks
    Raghavendra
     
     

    Subject: RE: Problem with regsub in TCL script
    Replied by: Raghavendra Gutty Veeranagappa on 02-08-2010 01:41:11 PM
    Hi Reinhard,
     
    Because you will get configuration param values as string , so you are passing string with { } value to the regsub command not as regular expression
     
    Thanks
    Raghavendra