there is a string txt file in which I want to match 123456 of the id=123456, that is, the parameter in url. There are more than 400 url, matching expressions in this txt.
there is a string txt file in which I want to match 123456 of the id=123456, that is, the parameter in url. There are more than 400 url, matching expressions in this txt.
python has a module to parse url
url_base = "http://www.baidu.com?id=123&name=name&passwd=passwd"
url_obj = urlparse(url_base)
query_obj = parse_qs(url_obj.query)
print query_obj
print query_obj['id']
print query_obj['name']
print query_obj['passwd']
output
{'passwd': ['passwd'], 'id': ['123'], 'name': ['name']}
['123']
['name']
['passwd']
\?id=(\d+)
var str = `
https://segmentfault.com/q/1010000016617094?id=123
https://segmentfault.com/q/1010000016617094?id=456
`;
str.match(/(?<=id=)\d+/g);
//["123", "456"]
Previous: Regular matching single-line comment problem
Next: Mengxin asked why php is in return'.. .' Call php;? > inside
the following html string. 3001 is variable. This visit is 3001, and the next visit may be 3002. You need to extract the number in this double quotation mark (that is, 3001 at this time). must also match the preceding , because there are many div, that...