I'm just loving Apollo. This morning I built a quick regex tester. It only does global style matches, but it is a good first draft. Download it by clicking the Download link below.
In the next version I'll switch to using highlight on the original text instead of a dump of matches. I'll also let you try out replacements as well.
Enjoy my lovely design skills. The code is below for those who are curious.
<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" title="Regular Expression Tester">
<mx:Script>
<![CDATA[
private function testRegex():void {
var regexStr:String = regex.text;
var bodyStr:String = body.text;
results.text = '';
if(regexStr == '' || bodyStr == '') {
mx.controls.Alert.show("Please enter a regex and a body.");
return;
}
var regexOb:RegExp = new RegExp(regexStr,"g");
var matches:Array = bodyStr.match(regexOb);
if(matches != null && matches.length > 0) {
for(var i=0; i < matches.length; i++) {
results.text += matches[i] + "\n";
}
}
}
]]>
</mx:Script>
<mx:VDividedBox width="100%" height="100%">
<mx:Panel title="Regex" width="100%" height="70" >
<mx:HBox width="100%" height="100%">
<mx:TextInput id="regex" width="100%" height="100%"/> <mx:Button id="tstButton" label="Test Regular Expression" click="testRegex()" height="100%" />
</mx:HBox>
</mx:Panel>
<mx:Panel title="Body" width="100%">
<mx:TextArea id="body" width="100%" height="100%" />
</mx:Panel>
<mx:Panel title="Matches" width="100%">
<mx:TextArea id="results" width="100%" height="100%" editable="false" />
</mx:Panel>
</mx:VDividedBox>
</mx:ApolloApplication>
Archived Comments
Nice Ray that's 2 apps for you and .1 for me the only thing I have made with Apollo is a Hello World app. Nothing like you stuff but at least I'm on the band wagon from the begging this time. I'm on Chapter 5 of "Adobe Flex 2: Training from the Source" and just ordered the Action Script 3.0 Cookbook.
I'm glad your take the time to talk about Flex and Apollo, it's helping me.
Ray is that just straight up javascript in your <![CDATA[ tag? Never knew you could do that.
Flex builder is complaining that var i has no type declaraction, and when i run my app it locks up when i submit the following.
regex
[0-9]*
body
123
It's not JS, its ActionScript 3. Both are based on ECMAScript, which is why it is so easy to learn one after you know the other.
Locks up eh? I bet I screwed something up in my loop.
I'm rewriting it RIGHT now to not use a textarea. Instead, I'm going to apply style sheets to the text matches.
After i read the code closer i realized it was AS. Guess it helps to actually read it. :)
It does not lock up if i use super simple RE like.
regex
123
body
abc123
Cant wait to the the CSS stuff. I have not seen code examples of that.
All this Apollo talk lately has gotten me depressed :) I want to be on the band wagon too. That's a cool little app you made Ray. Makes me want to stop right now and got try this Apollo stuff.
<rant>
Ugh. I know AS is so much like JavaScript (and I love JavaScript), but I always thought I could avoid having to learn AS since I stayed away from Flash. Now with Flex and Apollo, it seems inevitable that ActionScript will become yet another language web developers in the Adobe/ColdFusion realm will have to pick up.
What happened to the good old days when an app was written in one language? :-D
</rant>