Search Results

Search found 2 results on 1 pages for 'gojian'.

Page 1/1 | 1 

  • How to extract a couple marked strings from a line (python)

    - by GoJian
    My Friends, I spent quite some time on this one... but cannot yet figure out a better way to do it. I am coding in python, by the way. So, here is a line of text in a file I am working with, for example: "ref|ZP_01631227.1| 3-dehydroquinate synthase [Nodularia spumigena CCY9414]..." How can I extract the two strings "ZP_01631227.1" and "Nodularia spumigena CCY9414" from the line? The pairs of "| |" and brackets are like markers so we know we want to get the strings in between the two... I guess I can probably loop over all the characters in the line and do it the hard way. It just takes so much time... Wondering if there is a python library or other smart ways to do it nicely? Thanks to all!

    Read the article

  • Extract IP address from an html string (python)

    - by GoJian
    My Friends, I really want to extract a simple IP address from a string (actually an one-line html) using Python. But it turns out that 2 hours passed I still couldn't come up with a good solution. >>> s = "<html><head><title>Current IP Check</title></head><body>Current IP Address: 165.91.15.131</body></html>" -- '165.91.15.131' is what I want! I tried using regular expression, but so far I can only get to the first number. >>> import re >>> ip = re.findall( r'([0-9]+)(?:\.[0-9]+){3}', s ) >>> ip ['165'] In fact, I don't feel I have a firm grasp on reg-expression and the above code was found and modified from elsewhere on the web. Seek your input and ideas!

    Read the article

1