PY.RegExp.sub.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
RegExpSub=IN[2] ##Regexp substitution from IN[2]
##OUTPUT
Outlist = [] ##Outlist TRUE if match is find for each item in list
###Initialize Regexp
###The actual RegExp compare for each item in the list
for item in StrList: ## For each item in the list run a match
result=re.sub(regexExp, RegExpSub, item, 1)
Outlist.append (result)
##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