Rigging

Rigging101 » Rigging128

RE: String manipulation? (4 posts)

About This Topic

Tags

No tags yet.

  1. kwilli30

    offline
    Member
    Posted 8 years ago
    #

    Howdy folks.

    I'm writing a tool that works based on CV selection.

    string $cvs[] =

    ;
    // Result: curve1.cv[0] curve1.cv[1] curve1.cv[2] curve1.cv[3] curve1.cv[4] //

    I want to take the cv number, and pass that to a script

    kwCVtoLOC(0);
    kwCVtoLOC(1);
    kwCVtoLOC(2);
    ...

    What's the best way of stripping the "curve1.cv[" and "]" from the return?

    Thanks

  2. Andimation

    offline
    Member
    Posted 8 years ago
    #

    I would typically use a regular expression to extract the number. Here is one way -


    string $cv = "curve1.cv[10]";
    string $component = 'match "\\..*" $cv';
    print 'match "[0-9]." $component';

    You could make a more complex expression and combine the two, to do it on one line.

  3. kwilli30

    offline
    Member
    Posted 8 years ago
    #

    Wound up using
    string $component = (backtick)substitute "^[^.]*\\.cv" $node ""(backtick);
    Although I don't understand how "^[^.]*\\," and "\\.." work. How are these operators used?

  4. scroll_lock

    offline
    Member
    Posted 8 years ago
    #

    sorry for the offtopic plug , I just love this one:
    http://xkcd.com/208/

Reply

You must log in to post.

Rigging101 » Rigging128
1,099 posts in 307 topics over 110 months by 188 of 8,226 members. Latest: fashionpvp, d2q4p5z2j, gasheldonl