I am having a set of strings like this in a report field:
cpe:/o:redhat:enterprise_linux:7
cpe:/o:centos:centos:7
I need to extract the words after the second last colon ":"
ie.cpe:/o:centos:centos:7 -> should transform as centos:7
cpe:/o:redhat:enterprise_linux:7 -> should transform as enterprise_linux:7
There are some regular expressions in like
REGEXP_EXTRACT(string,[^:]+$) -> which gives me the last word after : but not the second last word
Please help with your suggestions. Thanks
2
Answers
You may use the following regex pattern:
Updated code:
Here is a regex demo showing that the pattern is working against your sample text.
Added
"
"
and a Capturing Group(
)
to the Answer by Tim Biegeleisen to ensure that theREGEXP_EXTRACT
Calculated Field captures the required values:Editable Google Data Studio Report and a GIF to elaborate: