I need help with creating a regex for PostgresSQL to extract specific url paths and place them into a separate column.
For example, using the following URLs I need to extract
https://example.com/drinks/
https://example.com/drinks/beverages/
https://example.com/drinks/beverages/pepsi/pepsi-can-16-oz/
Column 1 | Column 2
---------------------------------------------------------------------------------------
https://example.com/drinks | /drinks/
https://example.com/drinks/beverages | /drinks/beverage/
https://example.com/drinks/beverages/pepsi/pepsi-can-16-oz | /drinks/beverages/pepsi/
And lastly, a regex to get anything after /drinks/beverage/*
...
Regex isn't my strong suit so I'm looking for some guidance on how to accomplish this.
Copyright Notice:Content Author:「xiaohouzi」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58427542/regex-for-extract-for-url-path