I am trying to write a function which can make decisions about variables in the Workspace based on their names The function has no inputs and no outputs, so it must make decisions based off variable names alone. I am currently identifying the variable names using regular expressions such as:
varGroup1 = whos('regexp','glob*') % varType will be a struct containing all variables that start with 'glob'
I am able to assemble regular expressions which include certain substrings (as above), but am unable to figure out how to write a regular expression which discludes a substring. For instance, if I wanted to separate my Workspace variables into variables which do and do not start with 'glob'. I can include 'glob' variables, but I don't know how to disclude 'glob' variables to get the non-glob group. So far I have tried:
locVars = whos('regexp', '(?<!(glob))*')
Alternatively, if there is a better way to do it without using regular expressions I am open to other options. P.S. 'glob' does not mean global, it's just an example substring.
Best Answer