William Troup
William Troup

Reputation: 13131

Search for sentence that may containing different words in Python

In python, I have a string sentence as follows:

Change setting to value 50.

I essentially want to search for the sentence in a list of strings and extract the "setting" and "50" values, as they may be different.

I'm not terribly great with regular expressions, so any help would be greatly appreciated.

Upvotes: 0

Views: 90

Answers (1)

mayo
mayo

Reputation: 4075

Try this:

"Change (.*?) to value (.*?)\."

https://regex101.com/r/gG5sK3/2

Where the first and the second group are your desired values!

Upvotes: 3

Related Questions