get the value inside the tag with RegEx in Python

Question:

I want to get the value inside the tag with RegEx in Python

The value I want to get from inside the tag:

"a","b","c"

this tag:

tagstring = 'tag("a","b","c")'
Asked By: emanuel victor

||

Answers:

You can use this pattern "w","w","w":

import re
txt = 'tag("a","b","c")'
re.findall('"w","w","w"', txt)
Answered By: godot

If you want without Regular expressions then try – string.find

tagstring = 'tag("a","b","c")'
mask = tagstring[tagstring.find("(")+1:tagstring.find(")")]
print(mask)

output #

"a","b","c"
Answered By: Bhargav
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.