Update to my Apollo regex checker

I love you guys so much that I spent my lunch not just watching the Young and the Restless, but also improving my ugly little Apollo Regex Checker. (Ok, so I did watch Y and R while I coded.)

This new version now uses HTML mark up to show your matches, and lets you toggle between one match and multiple matches.

I have to say I really went down the wrong path trying to get my regex working right. Turns out there was a much simpler way to mark up the matches. This is my new AS code:

private function testRegex():void { var regexStr:String = regex.text; var bodyStr:String = body.text; var options:String = "";

if(regexStr == '' || bodyStr == '') {
	mx.controls.Alert.show("Please enter a regex and a body.");
	return;
}

if(global.selected) options = "g";
	
var regexOb:RegExp = new RegExp(regexStr,options);

//any matches?
if(!regexOb.test(bodyStr)) return;

body.htmlText = bodyStr.replace(regexOb,"<b>$&</b>");

} </code>

Next will be a version that lets you test replacements as well.

By the way - Apollo notices if you run the same AIR twice. It asks you if you want to replace the old version. Sweet.<p>Download attached file.</p>

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments