So, how to do that in groovy (or java)? I look for something like this:
someString.replaceN(/(?<=\p{L}) (?=\p{L})/, '', 3) // replace first 3 matches
For now, I only came to this stupid solution:
(0..2).each { s = s.replaceFirst(/(?<=\p{L}) (?=\p{L})/, '') }
In other languages it's easy as pie:
- Python - subn(count=3)
- PHP - preg_replace(limit=3)
- Rust - Regex.replacen