Vex String pattern matching

   9530   2   2
User Avatar
Member
132 posts
Joined: June 2016
Offline
Hi Guys ,
I have a quick question on string pattern matching and string replacement.

Basically I wanted to replace the name inside the ** pattern and match it with @path string.

if(match(("*%s*",name),s@path)

But It cant identify the **s and compares only with raw string “name”, can anyone please let me know how to do this.


below is my full code

s[]@groupNames = {"trunk","leaves","branch"};

foreach (string name; @groupNames)
{
    if(match(("*%s*",name),s@path)==1){
        setprimgroup(0,name,@primnum,1,"set");
    }
}

Thanks in advance.
Edited by Mohanpugaz - Dec. 15, 2017 03:30:40
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
User Avatar
Member
1746 posts
Joined: May 2006
Offline
Vex won't implicitly do printf style formatting, you'll need to use sprintf to do that:

s[]@groupNames = {"trunk","leaves","branch"};

foreach (string name; @groupNames)
{
    if(match(sprintf("*%s*",name),s@path)==1){
        setprimgroup(0,name,@primnum,1,"set");
    }
}
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
132 posts
Joined: June 2016
Offline
Hello Matt,
Thank you so much!That makes sense! And I learned a lot from your website its amazing source.
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
  • Quick Links