easy-module-attribute-getter icon indicating copy to clipboard operation
easy-module-attribute-getter copied to clipboard

Regular expression catching all colons followed by any character

Open mguillau opened this issue 4 years ago • 1 comments

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

mguillau avatar Sep 16 '21 12:09 mguillau

If I remember correctly, I was intending for a colon followed by a space to be acceptable

KevinMusgrave avatar Sep 17 '21 15:09 KevinMusgrave