Home > front end >  Regex get string not include double quotes python
Regex get string not include double quotes python

Time:03-09

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

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

CodePudding user response:

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.
  • Related