I'm working with a Google Data Studio field that has a page URL Path contained within it. Examples:
- /
- /sample-url
- /sample-url-2/
- /#sample-url-5/
- /sample-url-3/sample-url-4
- /sample-url-3/sample-url-6
In each one, I want to be capturing the bold portion in a custom formula/field--from the first slash, up to but excluding the second slash if there is one, and also including the first slash if that's the whole path. (In essence, the first subdirectory.) I would be open to recording the second backslash when there is one if that would make the solution simpler, but I'm guessing it's more complicated that way. I tried the following:
REGEXP_EXTRACT(Field, "^/[^/]+/$")
But it didn't work; everything returned null. What is wrong with that string?