views:

25

answers:

1
var aText:String = "C:\\folder\\folder\\file";
var filterVal:String = aText.toLowerCase().replace( /\//g, '/');
trace( aText );
trace( filterVal );

results as:

C:\folder\folder\file
c:\folder\folder\file

this code was based on this site and nascent regex skills.

What am I doing wrong? Thank you.

+3  A: 

you are doing it wrong, what you seem want \is:

var filterVal:String = aText.toLowerCase().replace( /\\/g, '/');

The initial and ending '/' delimit the Regular Expression. What is inside (\\) is what you are searching for. Since it's a backslash, you need to escape it.

Johnco
sorry, I should have matched title with code. i will remedy that now.
jedierikb
great, just edited my response removing the other option. Also clarified a bit how the RegExp is written.
Johnco
thx for the explanation. appreciated.
jedierikb