Re: Problem with find_replace

new topic     » goto parent     » topic index » view thread      » older message » newer message
include std/regex.e as re 
include std/console.e 
 
regex re_inlineCommands = re:new("<.*?<") 
 
sequence currentline = "here is some <bold<text> and some <italic<text> and <cmd 1, cm2, cmd3<multiple> and <bold<text>.\n" 
 
sequence inlineCommands = re:all_matches(re_inlineCommands, currentline) 
console:display( inlineCommands ) 
 
--{ 
--  { 
--    "<bold<" 
--  }, 
--  { 
--    "<italic<" 
--  }, 
--  { 
--    "<cmd 1, cm2, cmd3<" 
--  }, 
--  { 
--    "<bold<" 
--  } 
--} 
 
 
 
for i = 1 to length(inlineCommands) do 
    regex r = re:new(inlineCommands[i][1]) 
    currentline = find_replace(r, currentline, "<b>") 
end for 
 
puts(1, currentline) 
-- here is some <b>text> and some <b>text> and <b>multiple> and <b>text>. 

You have a small indexing error.

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu