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

    Regular Expression Help!

    andrewthorp Level 1

      "http://files.mydomain.com/accounts/5/file_assets/4/ezine/shoes_eagles2.jpg"

       

      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"
            creationComplete="init()">
            <mx:Script>
              <![CDATA[
                private function init():void{
                  acctTxt.text = txt.text.replace(/.*\/file_assets\/(.*)\/ezine\/.*/, "$1"); 
                  fileTxt.text = txt.text.replace(/.*\/ezine\/(.*).*/, "$1"); 
                }
              ]]>
            </mx:Script>
            <mx:Text id="txt" width="100%" text="http://files.mydomain.com/accounts/5/file_assets/4/ezine/shoes_eagles2.jpg"/>
            <mx:Form>
              <mx:FormItem label="Accnt num:">
                <mx:Text id="acctTxt"/>
              </mx:FormItem>
              <mx:FormItem label="File name:">
                <mx:Text id="fileTxt"/>
              </mx:FormItem>
            </mx:Form>
          </mx:Application>
          
          


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


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services