1 Reply Latest reply on Feb 7, 2010 7:22 AM by Gregory Lafrance

    Regular Expression Help!

    andrewthorp Level 1



      I have a string that looks like this, and I need to figure out two things:


      I need to find what is between 'file_assets/' and '/ezine' - In this case, '4'


      I also need to find what is bewteen ezine/ and " - In this case 'shoes_eagles2.jpg'


      Thanks so much!

        • 1. Re: Regular Expression Help!
          Gregory Lafrance Level 6

          You could improve this code, but this answers your question:


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                private function init():void{
                  acctTxt.text = txt.text.replace(/.*\/file_assets\/(.*)\/ezine\/.*/, "$1"); 
                  fileTxt.text = txt.text.replace(/.*\/ezine\/(.*).*/, "$1"); 
            <mx:Text id="txt" width="100%" text="http://files.mydomain.com/accounts/5/file_assets/4/ezine/shoes_eagles2.jpg"/>
              <mx:FormItem label="Accnt num:">
                <mx:Text id="acctTxt"/>
              <mx:FormItem label="File name:">
                <mx:Text id="fileTxt"/>

          If this post answers your question or helps, please mark it as such.

          Greg Lafrance - Flex 2 and 3 ACE certified


          Flex / AIR Development, Training, and Support Services