public function Sanitize(content:String):String
{
var filter_expression:String = "<.*?>";
var filter_pattern:Pattern = new Pattern(filter_expression);
var matcher:Matcher = new Matcher(filter_pattern, content);
return matcher.replaceAll("");
}
Everything compiles smoothly, but the output is difficult to understand.
I feel as though I must be missing something obvious here.
I'm trying to use the RegExp class to do very basic text replacement:
import org.as2lib.regexp.Pattern;
import org.as2lib.regexp.Matcher;
public function Sanitize(content:String):String
{
var filter_expression:String = "<.*?>";
var filter_pattern:Pattern = new Pattern(filter_expression);
var matcher:Matcher = new Matcher(filter_pattern, content);
return matcher.replaceAll("");
}
Everything compiles smoothly, but the output is difficult to understand.
For example,
Sanitize("apples"); returns "apples"
Sanitize("apples<oranges>"); returns null
What am I missing?
It seems like this forum is dead.
I am stuck using Actionscript 2.0 and don't have any other way to perform regular expressions.
Here is my working example:
import org.as2lib.regexp.Pattern;
import org.as2lib.regexp.Matcher;
var someText = "helloWorld1";
var pattern:Pattern = new Pattern("\\w+(\\d)");
var matcher:Matcher = new Matcher(pattern, someText );
label2.text = matcher.matches(); //returns "true"
label3.text = matcher.getGroup(1); //returns "1"