Regex required for following string [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
search?query=EasterGmPromo2020&searchType=mktgattribute&monet=CURATED&fulfillment=all
I have such type of strings. I wanted to get data from ?query=EasterGmPromo2020 only. How to do in regex.

This is a query string. There are many packages out there that parse URLs, no need for regex here.
One way is to use urllib.parse (built into Python 3)
from urllib import parse
params = parse.parse_qs("query=EasterGmPromo2020&searchType=mktgattribute&monet=CURATED&fulfillment=all")
print(params["query"])

Related

how can I observe a change in a python var [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Hi I'm trying to catch the change in the paperclip of my computer with the library pyperclip something same as
url=pyperclip.paste()
I want to create a thread which can append all the urls into a list my script, but I don't know how to could I do it
Thanks for your time and help c:
Did you check the documentation or the source code at all? That's all I did. pyperclip supports waitForPaste and waitForNewPaste methods that can do this.

Filtering string column with specific character [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a string column like this and want to filter content between "/" character:
A
9/17/001.a.x.y.16.04451
006.b.021017006814
2/17/000.c.m.n.15.00668/008
And the expected output is
A
001.a.x.y.16.04451
006.b.021017006814
000.c.m.n.15.00668
How could i make it done with python/R/Mysql
Thank youuu
In MySQL, you can use regexp_replace():
select t.*,
regexp_replace(a, '^[^/]+/[^/]+/([^/]*)[/|^]', '$1')
from t;
The logic is that you seem to want the third component between slashes if there is one. Otherwise, you seem to want the entire string.
Here is a db<>fiddle.

How to convert python RE module into ruby [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How would I convert the following code into ruby requivalent?
reg = re.compile(r"([\[\_\-\—]+[ ]*[\d\]]+[ ]*[\_\-\—\]]+[ ])", re.IGNORECASE)
reg.sub(lambda m: r'\n{}'.format(m.group()), s)
I believe this is the answer?
s = s.gsub(/([\[\_\-\—]+[ ]*[\d\]]+[ ]*[\_\-\—\]]+[ ])/i,'\n\1')

Python regex with re.findall [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I work with Python 2.7. It is my first question here.
Here is my code:
import re
string = "0581111105822222749533333"
result = re.findall(r'058',string) # ['058', '058']
I want to add 5 digits after 058 and receive:
# ['05811111','05822222']
How to do this?
Thank you.
You can extract what you need using 058\d{5} pattern. This matches '058' characters and keeps extracting 5 digits after those.

For web scraping through python, when should I use an html parser instead of lxml? Which is better and why? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
While I was trying to read Amazon's data, I noticed little difference in the outputs when I used an lxml parser instead of html. Which one should I prefer and why?
Are you using BeautifulSoup for parsing? If so then read the documentation.
https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser
https://www.crummy.com/software/BeautifulSoup/bs4/doc/#differences-between-parsers

Categories