Is there a way to switch compilation or use metacharacters when compiling regular expressions? The current code looks like this:
Current code:
import re the_value = '192.168.1.1' the_regex = re.compile(the_value) my_collection = ['192a168b1c1', '192.168.1.1'] my_collection.find_matching(the_regex) result = ['192a168b1c1', '192.168.1.1']
An ideal solution would look like :
import re the_value = '192.168.1.1' the_regex = re.compile(the_value, use_metacharacters=False) my_collection = ['192a168b1c1', '192.168.1.1'] my_collection.find_matching(the_regex) result = ['192.168.1.1']
An ideal solution would allow the library to re handle the disconnection of metacharacters to avoid the need to get as much involved in the process as possible.
source share