0

What is the {%d} for in these regexp? I've read: the re doc but I could not something about it (except maybe this part) .

B = r'( {%d})'

N = r'(\d{%d})'
NB = r'([0-9 ]{%d})'

A = r'(\w{%d})'
AB = r'([a-zA-Z ]{%d})'

AN = r'([a-zA-Z0-9]{%d})'
ANB = r'([a-zA-Z0-9 ]{%d})'

AMT = r'(\d{13}[{}A-R]{1})'

ALL = r'(.{%d})'
codeblur
  • 438
  • 1
  • 3
  • 8
  • A literal {%d} sequence in a raw string literal. – Wiktor Stribiżew Oct 18 '15 at 19:52
  • `%d` is not related to regex but only to C formatted strings. In this ways you can replace the placeholder `%d` (that stands for an integer) later: `'I have %d apples in my bag' % number_of_apples` – Casimir et Hippolyte Oct 18 '15 at 19:58
  • Yes, I've just realized that. I thought it had special meaning. I sometimes forget that r means RAW and not RegEx... Thanks! – codeblur Oct 18 '15 at 20:11
  • Regex are strings first, regex later. So `r''` doesn't mean it's contents can't be regex. –  Oct 18 '15 at 21:50

0 Answers0