re:find_replace_callback() -- example fails

new topic     » topic index » view thread      » older message » newer message

Example 1 in the documentation for find_replace_callback() is not working.

A cut and paste copy of the example produces an error...


include std/regex.e as re 
include std/console.e 
 
function my_convert(sequence params) 
    switch params[1] do 
        case "1" then 
             return "one " 
        case "2" then 
             return "two " 
        case else 
             return "unknown " 
    end switch 
end function 
regex r = re:new(`\d`) 
sequence result = re:find_replace_callback(r, "125", routine_id("my_convert")) 
-- result = "one two unknown " 
 
display( result ) 
 
/* 

bash-3.1# eui demo 
 
demo.ex:5 in function my_convert() 
A machine-level exception occurred during execution of this statement 
 
... called from /root/euphoria/include/std/regex.e:1218 in function find_replace_callback() 
 
... called from demo.ex:15 
 
--> See ex.err 
*/ 
 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu