'Extract id from URL using regex
I'm trying to figure out how to extract the 32 character id from the URL below:
https://digital-joshua.notion.site/84c7a26fb7aa4a0495a8e89a667a68a7?v=ceec49c8ec18473bbc1965ea17eb8868
This would be the intended output:
84c7a26fb7aa4a0495a8e89a667a68a7
✅ UPDATE:
@LukStorms solution achieves this:
\b[0-9a-f]{32}\b
Solution 1:[1]
We can use a positive or negative look-behind so as to only return the string that we want.
- either we say that we want a slash
/just before
(?<=\/)[0-9a-f]{32}
- or we say that we don't want an equals sign
=
(?<!=)[0-9a-f]{32}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
