-1

I have a list of urls of the following format:

https://doi.org/10.1145/2883851.2883900

I want to extract the values after "doi.org".Here in the example my expected output is:

10.1145/2883851

I could do it on single url but to apply how get the values from a list of URLs.

7
  • 1
    if its the same website: extracted = [string.replace("https://doi.org/", "") for string in lst] Commented Oct 7, 2020 at 18:32
  • for string i in lst I think you wanted, or am I wong? Commented Oct 7, 2020 at 18:35
  • yeah, sorry idk how i put in in twice Commented Oct 7, 2020 at 18:37
  • 1
    also possible duplicate? stackoverflow.com/questions/12023430/regex-url-path-from-url Commented Oct 7, 2020 at 18:38
  • If you could do it to a single URL, doing it for all URLs in a list is a simple matter of iterating over the list. It looks like you might find a python tutorial helpful. There are many good ones online. Here's a good one: learnpython.org/en/Loops Commented Oct 7, 2020 at 18:39

1 Answer 1

2

If you have a list of urls with the same domain name and want to return a list of values in 10.1145/2883851 format :

def replace_url(urls):
    result = []
    for url in urls:
        result.append(url[16:]) # len of "https://doi.org/" is 16
    return result 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.