easy-module-attribute-getter
easy-module-attribute-getter copied to clipboard
Regular expression catching all colons followed by any character
https://github.com/KevinMusgrave/easy-module-attribute-getter/blob/e0a733c02f2e6a969191a75c79159f45440c969f/easy_module_attribute_getter/yaml_reader.py#L29
As described in the title, this regular expression captures all colons followed by a character, whitespace (\s) or not (\S). Should be \S only, I believe.
>>> import re
>>> colon_followed_by_char = re.compile(":[\s\S]")
>>> bool(colon_followed_by_char.search('{invalid:[]}'))
True
>>> bool(colon_followed_by_char.search('{valid: []}'))
True
>>> import re
>>> colon_followed_by_char = re.compile(":[\S]")
>>> bool(colon_followed_by_char.search('{invalid:[]}'))
True
>>> bool(colon_followed_by_char.search('{valid: []}'))
False
If I remember correctly, I was intending for a colon followed by a space to be acceptable