1

I'm having cells like

10 (1880 15) ; 11 (1880 15) ; 12 (1880 15) ; 7 (1880 15) ; 3 (1880 15) ; 9 (1880 15) ; 2 (1880 15) ; 1 (1880 15) ; 4 (1880 15) ; 5 (1880 15) ; 6 (1880 15) ; 8 (1880 15)

and I want to take all the text inside the parentheses. Using this expression it gives me a Null result:

value.match(/\(.*?\)/)

Why that? Thanks

Lara M.
  • 855
  • 2
  • 10
  • 23
  • 1
    How does the `match` API work? Does it repeatedly check for a pattern, does it check for the first match, or something else? – Tim Biegeleisen Jan 08 '19 at 09:59
  • They see `match(/.../)` and suddenly think about JS. – revo Jan 08 '19 at 10:03
  • `value.match(/\(([^()]*)\)/` gives always Null. I don't really understand the work of `match`: I found that https://stackoverflow.com/questions/17896772/value-match-regex-in-google-refine but I think it doesn't work with my case. – Lara M. Jan 08 '19 at 10:04
  • 1
    Just for the record, [here is the documentation of this function](https://github.com/OpenRefine/OpenRefine/wiki/GREL-String-Functions#matchstring-s-regexp-p). – Ettore Rizza Jan 08 '19 at 10:25

1 Answers1

3

The match function does not work as you think. It is very counter-intuitive. That's why since Open Refine 3 there is a find function that does exactly what you want.

value.find(/\(.*?\)/)

enter image description here

Ettore Rizza
  • 2,800
  • 2
  • 11
  • 23