This is a continuation from this post about how to mimic Marcedit capturing group Find/Replace in Open Refine.
The one problem with mimicking the Marcedit Find/Replace is that it will wipe out the data you don't want to alter unless you facet it out first. This is kind of cumbersome and still doesn't have the convenience of Marcedit's Find/Replace.
However, the if function takes care of that problem. I'm going to post the recipe here at the top and then go into detail further down. So, for your capturing group find of value.match(/<capturing group regex>/), do a transform cells, and drop it into this statement:
if(isNotNull(value.match(/<your find>/)), <your replace>, value)
Showing posts with label isNotNull. Show all posts
Showing posts with label isNotNull. Show all posts
Friday, July 28, 2017
Unpacking value.match with reg ex and how to use it in boolean statements
The value.match documentation on the Open Refine github wiki is a bit daunting, so I'm going to try to break it down in this post.
Some programming speak first: GREL functions usually yield some sort of data after they're done doing their thing. That data is called a return value. So, that's what I'm referring to whenever I make statements like, "match returns <whatever>".
Anyway, the biggest hurdle to my understanding was figuring out how match and regular expressions worked together. Here's what I've determined:
Unlike Marcedit, you have to account for the whole line if you're using regex in match.
Subscribe to:
Posts (Atom)