forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstripSlashes.as
More file actions
24 lines (21 loc) · 729 Bytes
/
stripSlashes.as
File metadata and controls
24 lines (21 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package utils.string
{
/**
* Returns the string with slashes removed from all characters specified in the <code>chars</code> parameter
* @param str the string to return stripped of slashes
* @param chars the string of chars to remove slashes from
* @return
*/
public function stripSlashes(str:String, chars:String = "\""):String
{
// return the unaltered string if str or chars are null or empty
if (!str || !chars)
return str;
// slash unsafe characters
chars = slashUnsafeChars(chars);
// build the regular expression that removes the slashes
var regex:RegExp = new RegExp("\\\\([" + chars + "])", "g");
// strip the slashes from the specified characters
return str.replace(regex, "$1");
}
}