Reputation: 2881
I have this google sheets table with input in column A
I need this output on the right.
Input | Desired Output |
---|---|
"https://www.example.com/sub.php?id=54128754" | https://www.example.com/sub.php?id=54128754 |
"https://www.example.com/sub-new-45184832/" | https://www.example.com/sub-new-45184832 |
"https://www.example.com/sub-new2-495174885/" | https://www.example.com/sub-new2-495174885 |
But when trying this formula:
=ArrayFormula(REGEXEXTRACT(A2:A4, "(.+)[\""|\/]"))
This is what I came up with.
Input | Output |
---|---|
"https://www.example.com/sub.php?id=54128754" | "https://www.example.com/sub.php?id=54128754 |
"https://www.example.com/sub-new-45184832/" | "https://www.example.com/sub-new-45184832/ |
"https://www.example.com/sub-new2-495174885/" | "https://www.example.com/sub-new2-495174885/ |
How to extract everything between "(*)"
, or "(*)/"
.
In other word if ended with "
or /"
Thanks in advance.
Upvotes: 0
Views: 52
Reputation: 50382
The regex is simple:
"
: ^"
()
anything but "
: [^"]
"
: "$
"
is a argument delimiter, we need to escape "
by doubling it: ""
."^""([^""]+)""$"
If you want to remove the last /
as well, make the capture group non-greedy(+?
) and add /
before the "
as optional:
"^""([^""]+?)/?""$"
Upvotes: 1