Предыдущий ответ не работал для меня.Вот что сработало (Использование Flex 4.5):
public class FileNameSanitizer
{
public static function sanitize( fileName:String ):String
{
var p:RegExp = /[:\/\\\*\?"<>\|%]/g;
return fileName.replace( p, "" );
}
}
И тестовый сценарий, чтобы доказать это:
import flexunit.framework.TestCase;
public class FileNameSanitizerTest extends TestCase
{
public function FileNameSanitizerTest()
{
}
public function testSanitize():void
{
assertEquals( "bla", FileNameSanitizer.sanitize( "bla" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla/foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla\\foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla:foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla*foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla?foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla\"foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla<foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla>foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla|foo" ) );
assertEquals( "blafoo", FileNameSanitizer.sanitize( "bla%foo" ) );
assertEquals( "", FileNameSanitizer.sanitize( "/\\:*?\"<>|%" ) );
}
}