Adding a hyphen to cells in an ISSN column in Open Refine

20 views Asked by At

Does anyone know the correct GREL for transforming cells in a column so that instead of '12456789' the string shows '1245-6789'? I want to apply this to all the different values of the cells in the column. Thanks

I was going to use the Edit Facet Expression based on Column.

1

There are 1 answers

0
Aaron Meese On

One way to do this is with a regular expression that will look for strings of eight number characters and replace them with the new format. According to the GREL documentation and this forum post, one way to do that is as follows:

'12456789'.replace(/(\n{4})(\n{4})/, "$1-$2")

This works by taking a capture group of the first four numbers and a capture group of the final four numbers, then replacing that string with a string that has a hyphen between the two groups.