Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I ended up doing this a different way, since none of the above worked. First I found the fields like @cat, with this: </p> <pre><code>attributes = re.findall('(?:@)([^\( ]*)', query) </code></pre> <p>Next, I found the more complicated ones, with this:</p> <pre><code>regex0 = re.compile(''' @ # at sign (?: # start non-capturing group \w+ # non-whitespace, one or more \b # a boundary character (i.e. no more \w) | # OR ( # capturing group \( # left paren [^@(),]+ # not an @(), (?: # another non-caputing group , * # a comma, then some spaces [^@(),]+ # not @(), )* # some quantity of this non-capturing group \) # a right paren ) # end of non-capuring group ) # end of non-capturing group ''', re.VERBOSE) # and this puts them into the attributes list. groupedAttributes = re.findall(regex0, query) for item in groupedAttributes: attributes.extend(item.strip("(").strip(")").split(", ")) </code></pre> <p>Next, I checked if the attributes I found were valid, and added them (uniquely to an array):</p> <pre><code># check if the values are valid. validRegex = re.compile(r'^mice$|^mouse$|^cat$|^dog$') # if they aren't add them to a new list. badAttrs = [] for attribute in attributes: if len(attribute) == 0: # if it's a zero length attribute, we punt continue if validRegex.search(attribute.lower()) == None: # if the attribute from the search isn't in the valid list if attribute not in badAttrs: # and the attribute isn't already in the list badAttrs.append(attribute) </code></pre> <p>Thanks all for the help though. I'm very glad to have had it!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload