0

I'm wondering if it is possible to use "groups" in ReGeX used in Open Refine GREL syntax. I mean, I'd like to replace all the dots followed and preceded by a character WITH the same character and dot but followed by a space and then the character.

Something like:

s.replace(/(.{1})\..({1})/,/(1).\s(2)/)
pnuts
  • 58,317
  • 11
  • 87
  • 139
mellin
  • 307
  • 5
  • 13

2 Answers2

1

It should, but your last argument needs to be a string, not a regular expression. Internally Refine uses Java's Matcher#replaceAll method which accepts a string argument.

Tom Morris
  • 10,490
  • 32
  • 53
1

I think I found out how to deal with this. You need to put $X in your string value to address a Xth capture group.

It should be like this:

s.replace(/.?(#capcure group 1).?(#capcure group 2).*?/), " some text $1 some text $2 some text")

Stan
  • 11
  • 1