Skip to main content
added 194 characters in body
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

Red, 89 bytes

func[s t n][reverse t either parse r: reverse copy s[n to remove t to end][reverse r][s]]

Try it online!

Working on a reversed copy of the string, I use parse to remove n times the reversed substring. If parse succeeds, I return the modified string reversed, otherwise - the original string.

Red, 89 bytes

func[s t n][reverse t either parse r: reverse copy s[n to remove t to end][reverse r][s]]

Try it online!

Red, 89 bytes

func[s t n][reverse t either parse r: reverse copy s[n to remove t to end][reverse r][s]]

Try it online!

Working on a reversed copy of the string, I use parse to remove n times the reversed substring. If parse succeeds, I return the modified string reversed, otherwise - the original string.

Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

Red, 89 bytes

func[s t n][reverse t either parse r: reverse copy s[n to remove t to end][reverse r][s]]

Try it online!