Thread: string.escape()
View Single Post
  #17  
Old 04-05-2010, 06:13 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Modified Dusty's replacetext() function into a simple stripslashes() function. It wakes into account new lines (\n). I don't know if there's more to take into account, since I really only needed to script something so that it doesn't ruin new lines.
PHP Code:
function stripslashes(txt,a,b) { 
  
// a=\ b=""
  
if (txt.pos(a)<0) return txt
  
temp.txtpos txt.positions(a); 
  
temp.newtxt txt.substring(0,txtpos[0]); 
  for (
temp.i=0;i<txtpos.size();i++) { 
    if(
txt.substring(txtpos[i]+1,1) == "n") {
      
newtxt @= "\\n";
      
newtxt @= txt.substring(txtpos[i]+a.length()+1,txt.substring(txtpos[i]+a.length()+1).pos(a));
    }
    else {
      
newtxt @= b
      
newtxt @= txt.substring(txtpos[i]+a.length(),txt.substring(txtpos[i]+a.length()).pos(a)); 
    }
  } 
  return 
newtxt

Use: stripslashes(mystring, "\\", "");
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote