I have a string like this patern: "abcd abcd | abcde | Degree SP | xyz abcd | abcd ABC"
I need to extract "Degree SP"
using regular expressions. How can I do that? The condition here are:
I'm trying the Google Sheet formula REGEXEXTRACT(<input string>, "[\|\s].+SR[\s\|]")
It returns " | abcde | Degree SP "
. How can I restrict to extract from the last "|"?
If the string Degree SP
should be between pipes and a space:
\|\s([^\s|][^|]*SP)\s\|
\|\s
Match |
and a whitespace char(
Capture group 1
[^\s|]
Match a single char other than a space or |
[^|]*SP
Match optional chars other than |
and match SP)
Close group 1\s\|
Match a whitespace char and |
If only the pipe after Degree SP
is mandatory:
([^\s|][^|]*SP)\s*\|