py.RegExp.py
import re ##Import for re or Regular Expressions
###INPUTS (Two Inputs- 0 and 1- ad inputs to python node to correspond with th [+] button)
StrList=IN[0] ##Simple list of items to match
regexExp=IN[1] ##Regexp string to match
##see https://docs.python.org/3.3/howto/regex.html "Regular expressions in dynamo" and
##https://regex101.com for regular expressions 101 testing
##OUTPUT
Outlist = [] ##Outlist TRUE if match is find for each item in list
###Initialize Regexp
Regex = re.compile(regexExp, re.IGNORECASE)
###The actual RegExp compare for each item in the list
for item in StrList: ## For each item in the list run a match
Outlist.append ( Regex.match(item) is not None) ##If match is not NONE then it is a match (true) - else (false)- append that to the list for each item
OUT=Outlist ##Set output to results
Comments
Post a Comment