A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Help needed about regexp

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    83

    Help needed about regexp

    Hi, I want to remove string starts with -

    can anyone help me?

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    This should get you started.

    Actionscript Code:
    var str:String = "- My String, test test.";
    var re:RegExp = /^-\s?/;// Search for a string that starts with "-" or "- "

    // String before changes
    trace(str);

    // If the string starts with - or -(space) then replace it
    if(re.test(str))
    {
        while(re.exec(str) != null)
        {
            str = str.replace(re, "");
        }
    }

    // String after changes
    trace(str);

  3. #3
    Member
    Join Date
    Nov 2007
    Posts
    83

    Thumbs up Solved

    thanks for the reply. /-.*/g works fine.

  4. #4
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    That pattern would match any string with a - in it, no matter what the position. Doesn't appear to work in my tests but if it works for you then problem solved.

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