Results 1 to 3 of 3

Thread: (ANOTHER) Lua syntax question

  1. #1
    Join Date
    May 2004
    Posts
    2,589

    Default (ANOTHER) Lua syntax question

    can someone please give me a kick in the right direction?
    Code:
    local s = string.gsub(mc12.playback.track),("^%d+ %s*%-?%s*")," ",nil
    print (mc12.playback.track)
    print (s)
    returns:

    [string "CERBERUS_4-4.gml:\Audio\PC\JRMC 12\Zone 1\T..."]:1: bad argument #2 to `gsub' (string expected, got no value)
    stack traceback:
    [C]: in function `gsub'
    [string "CERBERUS_4-4.gml:\Audio\PC\JRMC 12\Zone 1\T..."]:1: in main chunk

    TY
    Beware of the robot.

  2. #2
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Try

    Code:
    local s = string.gsub(mc12.playback.track,"^%d+%s*%-?%s*","",nil)
    My reading of this is that it should remove any numbers at the start of the string followed by any number of spaces, an optional single dash and any number of spaces.

    Is that what you wanted to do?
    --Rob

  3. #3
    Join Date
    May 2004
    Posts
    2,589

    Default

    Hi Rob,
    yeah, that's more or less what I wanted to do, but is there a way of improving it to remove any punctuation as well? Namely periods, if I need to be more specific. I'd also like to remove brackets, underscores and hyphens. I'll substitute the ampersand symbol with the word "and" beforehand.

    Thanks! It works great so far.
    Last edited by quixote; August 22nd, 2008 at 12:42 PM.
    Beware of the robot.

Posting Permissions

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