dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Some RegExp Help Please

  1. #1
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626

    [RESOLVED] Some RegExp Help Please

    Hello,

    I've never used regular expressions before and I'm trying to get my head around search patterns.

    If i was to have the following string: "log^2(34)", how would i get the digits between the "^" and "(", and the digits between the "(" and ")" ?

    Cheers,

    Zlatan
    Last edited by dudeqwerty; 12-21-2006 at 10:43 AM.
    New sig soon

  2. #2
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    Ah, i figured it out:
    the pattern to look for: log^whatever( is
    Code:
    var basePattern:RegExp = /log\^.*?\(/;
    and for: (whatever) :
    Code:
    var bracPattern:RegExp = /\(.*?\)/;
    HTH,

    Zlatan
    New sig soon

  3. #3
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    If you want only the numbers you can do this.

    var rgp1:RegExp = /[0-9]/;
    var str1:String = "log^2(34)";
    var result1:Object = rgp1.exec(str1);
    trace("R1: "+result1);//2
    //
    var rgp2:RegExp = /[0-9]()[0-9]/;
    var str2:String = "log^2(34)";
    var result2:Object = rgp2.exec(str2);
    trace("R2: "+result2);//34
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  4. #4
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    Thanks CF!
    New sig soon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center