I'm trying to create a system where the user will input their Wikipedia page link, and the application will get the page title from Wikipedia page URL.
Like, if the user gives: https://id.wikipedia.org/wiki/Eminem
, I want to get the page title Eminem
.
Or if the user gives: https://id.wikipedia.org/wiki/Eminem#1992%E2%80%931997:_Awal_karier,_Infinite_dan_masalah_keluarga
, I want the page title, which is Eminem
I've tried finding a regex pattern. I'm thinking about what if I could create/ find a regex pattern that would find words that sit between /wiki/
and ends with a /
. So far didn't found any way to do that.
So what can I do? What other options I have?
this would partly work: /(?<=https?:\/\/..\.wikipedia\.org\/wiki\/).+(?=\/(.+)?|#)/
It doesn't work without a / at the end though.