Reputation: 89
I am trying to use the value.findall()
function in OpenRefine 3.4 by finding all the rows in a column that contain specific strings i.e., "WASHER
", "FLAT
", "10MM
" and "SS
"` in any random order given and return that into a new column. Here is a snippet of my codes.
import re
regex=r"(\WASHER)(\"FLAT")(\"10MM")(\"SS")"
return re.findall(regex, value)
Here is what am what screen looks like.
Upvotes: 1
Views: 216
Reputation: 626903
You need to put the following code into the box:
import re
regex=r'^(?=.*\bWASHER\b)(?=.*\bFLAT\b)(?=.*\b10MM\b)(?=.*\bSS\b).*'
return re.findall(regex, value)
This will return a whole string that contains WASHER
, FLAT
, 10MM
and SS
as whole words anywhere in the string.
See the regex demo.
If they occur in immediate succession, you can use
regex=r'.*?\bWASHER\s+FLAT\s+10MM\s+SS\b.*'
See this regex demo.
Upvotes: 2