Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex get string not include double quotes python

I am working on a web scrapper and I have a js string like this.

Package Title: ('"id"', ':', '1', ',', '"title"', ':', '"', '11 Dofollow and 500 Words Article')
Package Title: ('"id"', ':', '2', ',', '"title"', ':', '"', 'Basic Page and Privacy Policy Page')
Package Title: ('"id"', ':', '3', ',', '"title"', ':', '"', '2x Standart Page')

I want to like this, how can I do this?

11 Dofollow and 500 Words Article
Basic Page and Privacy Policy Page
2x Standart Page

I tried this but not working

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

package = re.findall(r'\'^[^"](.*?)^[^"]\'',str(jsstring))
print(package)

>Solution :

You can use

re.findall(r"'([^']*)'\)", str(package_title_match))

See the regex demo. Details:

  • ' – a single quote
  • ([^']*) – Group 1: any zero or more chars other than a single quote
  • '\) – a ') substring.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading