0

I want to eventually be able to increment an integer within my Regex, but the braces are preventing me from doing so.

So far I have:

start = 6
m = re.search(r"(.{{n},}).*?\1".format(n=start), s)
return m.group(1)

However, I get `ValueError: Single '}' encountered in format string

I am using Python 2.7.

0

1 Answer 1

1

What about using a different method of string formatting:

m = re.search(r"({.%s,}).*?\1" % start, s)
Sign up to request clarification or add additional context in comments.

1 Comment

D'oh, thanks for that. Completely forgot about that usage...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.