Reputation: 215
For a string like this,
"By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service."
I want to cut the string from last occurrence of 'our' to get the result: " Terms of Service."
Upvotes: 1
Views: 2803
Reputation: 785058
Using bash
you can do this:
s="By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service."
echo "${s##*our }"
Terms of Service.
If you cannot use bash
for some reason then this awk
should work:
awk -F 'our ' '{print $NF}' <<< "$s"
Terms of Service.
Upvotes: 2