Search Unity

Regex question

Discussion in 'Scripting' started by hannes-dev, Sep 4, 2012.

  1. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    hi, i want to modifie this script: http://wiki.unity3d.com/index.php/FbxAnimListPostprocessor
    so it first reads the name, and then the animation data
    i already tried a few things, poked a bit here: http://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial
    but cant seem to get it working

    so i want to change this (works) :
    Code (csharp):
    1.  
    2.         Regex regexString = new Regex(" *(?<firstFrame>[0-9]+) *- *(?<lastFrame>[0-9]+) *(?<loop>(loop|noloop| )) *(?<name>[^\r^\n]*[^\r^\n^ ])",
    to something like this
    (this code doesnt work)
    :
    Code (csharp):
    1.  
    2. Regex regexString = new Regex(" *(?<name>*[^ ]) *(?<firstFrame>[0-9]+) *- *(?<lastFrame>[0-9]+) *(?<loop>(loop|noloop| |\n))",
    3.        
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Going by what you have there I would assume that you are missing the ^ in front of the last \n
     
  3. hannes-dev

    hannes-dev

    Joined:
    Apr 27, 2012
    Posts:
    132
    i have a seperate txt file where i manually write the animation data
    and the loop is optional, so thats why i didnt add a ^

    i think if someone could explain to me what *(?<name>[^\r^\n]*[^\r^\n^ ]) exactly does
    why is there a * at the beginning
    what i understand of this code is :

    mysterious *, not \r , not \new line, * : keep looking until you find \r or \n , and then this piece [^\r^\n^ ], whats this for

    adding ^\n doesnt work
     
    Last edited: Sep 4, 2012