-2

Given:

s = '2X-Large/3X-Large (4 Count)'

Can someone suggest how to extract 4 from s using regex in Python?

0

1 Answer 1

0

You may use re.findall here:

s = "2X-Large/3X-Large (4 Count)"
counts = re.findall(r'\((\d+) Count\)', s)
print(counts)

This prints:

['4']
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.