I'm trying to remove case-insensitively the value of cell 'artist' from the current cell (which is a song name). I know that replace()
can take regex as argument (https://github.com/OpenRefine/OpenRefine/wiki/GREL-String-Functions#replacestring-s-string-f-string-r) and I can use (?i)
for case-insensitive mode.
But how does replace()
know whether its argument is a regex or plain string? All examples I've seen use /.../
to denote a regex, but I need to make a "dynamic" regex by concatenating the cell artist
.
So these don't work:
value.replace('(?i)'+cells['artist'].value+,"")
value.replace('((?i)'+cells['artist'].value+')',"")
value.replace('/(?i)'+cells['artist'].value+'/',"")
I'd prefer to do this with GREL, but a solution with Python/jython will also work. Thanks!