Is it possible to match multiline strings with match() function? I tried to apply match(/(abc)\rdef/) to a cell containing 2 lines of text abc & def, but it does not work. Is there a way to get "abc" as result?
Asked
Active
Viewed 100 times
1
2 Answers
0
Simply use \n
(newline) instead of \r
(carriage return).
value.match(/(abc)\ndef/)
But you have to indicate where the newline is. match
has no "multliline" parameter, so the dot (.
) doesn't match line breaks.

Ettore Rizza
- 2,800
- 2
- 11
- 23
0
Of course ! Thanx Ettore
And I found a way to do what I wanted with value.match(/(.*?\n)*(def)\n?(.*?\n?)*/)

Mathieu Saby
- 125
- 5
https://stackoverflow.com/questions/50758805/text-with-n-matching-in-regex-and-openrefine/50759334#50759334 – B. Go Jan 31 '19 at 00:37