3

I have a string of the following format:

TEXT####TEXT####SPECIALTEXT

I need to get the SPECIALTEXT, basically what is after the second occurrence of the ####. I can't get it done. Thanks

Matthew Warman
  • 3,234
  • 2
  • 23
  • 35
user1894933
  • 61
  • 1
  • 1
  • 5

2 Answers2

15

The regex (?:.*?####){2}(.*) contains what you're looking for in its first group.

sp00m
  • 47,968
  • 31
  • 142
  • 252
0

If you are using shell and can use awk for it:

From a file:

awk 'BEGIN{FS="####"} {print $3}' input_file

From a variable:

awk 'BEGIN{FS="####"} {print $3}' <<< "$input_variable"
sampson-chen
  • 45,805
  • 12
  • 84
  • 81