View Full Version : when flash sees \ i want it to make it \\.
Templarian
April 11th, 2005, 06:36 PM
descriptive title...
how would i make the string c:\folder1\folder2\file.txt become c:\\folder1\\folder2\\file.txt
something with spliting a string but dont have the knowledge to do it. Tried for about 20min on my own with this problem but kinda stuck.
Jack_Knife
April 11th, 2005, 07:17 PM
Find the string replace function (I can't remember what it is in AS at the moment) and replace all "\" with "\\". You'll need to escape the slashes though, I think. So it'll be replacing "\\" with "\\\\". I think.
EmeniusXp
April 11th, 2005, 07:24 PM
got this code from sephiroth.it
// -----------------------
// Replace single or
// multiple chars in a
// String.
// The original string is
// not affected.
//
// Based on a idea of
// Davide Beltrame (Broly)
// mail: davb86@libero.it
// -----------------------
String.prototype.replace = function()
{
var arg_search, arg_replace, position;
var endText, preText, newText;
arg_search = arguments[0];
arg_replace = arguments[1];
if(arg_search.length==1) return this.split(arg_search).join(arg_replace);
position = this.indexOf(arg_search);
if(position == -1) return this;
endText = this;
do
{
position = endText.indexOf(arg_search);
preText = endText.substring(0, position)
endText = endText.substring(position + arg_search.length)
newText += preText + arg_replace;
} while(endText.indexOf(arg_search) != -1)
newText += endText;
return newText;
}
// ---------------------
// USAGE:
// ---------------------
originalString = "This is the original ****ing text. What the hell are you typing?"
replacedText = originalString.replace('****','***');
trace("-----------------------------");
trace("original was: " + originalString);
trace("replaced is: " + replacedText);
Templarian
April 11th, 2005, 07:58 PM
that was fast i went outside for like a few min... Thanks a bunch emeniusXP.
you too would of took me a while to figure out that becuase \n is a function anything after it will be taken out so i would have to represent \ with\\.
thanks
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.