How to match data column with its own regex in another column. Here is how it looks like.
Data Regex
0 HU13568812 ^HU[0-9]{8}
1 78567899 ^NO[0-9]{5}
2 AT1234567 ^HU[0-9]{7}
The output will be a new column for the result if its match (1) or not match (0) like this.
Data Regex Match
0 HU13568812 ^HU[0-9]{8} 1
1 78567899 ^NO[0-9]{5} 0
2 AT1234567 ^AT[0-9]{7} 1
I tried to use re.match() but I can't seem to get it match for the whole row at once. Is there any better way to do this in a simple function or more pythonic way? Thank you.
re.matchonly matches at the start of string and does not anchor the match at the end of string. Can you changeRegexcolumn values by adding$at the end?