Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying pass year variable to re.findall, but it doesn't work(no errors). Can anyone specify where I'm going wrong?

links = re.findall(r"('+year+'-.*\/t.*.html)", line)

share|improve this question
What is r here? – i08in Oct 3 '13 at 5:47
r ---> Raw string – Naive Oct 3 '13 at 5:49
up vote 1 down vote accepted

year should be out of the quotes, since it is a variable:

year = 2013
links = re.findall(r + '(' + str(year) + '-.*\/t.*.html)', line)
share|improve this answer
r is not a variable but denotes raw string. This should probably be: r'(' + str(year) + r'-.*... – Javier Rivera Oct 4 '13 at 6:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.