user1619176
user1619176

Reputation: 15

Regex python Match after and before a specific string

Lets say we have this string:"Code:1,Some text some other text {fdf: more text, attr=important "

I want to catch the pattern using Regex that can findall attr and extract important and 1 and put them in dict.

I tried this one:

(?<=testcaseid_)[^_]+_[^_]+

but still capture all the previous

Upvotes: 1

Views: 92

Answers (1)

zukowski2012
zukowski2012

Reputation: 26

I'm not sure if I understand well, but if you want to get everything starts from "1" to something after attr= you can also use regex like this:

r"1.*?attr=\w+"

Upvotes: 1

Related Questions