fork(1) download
  1. import re
  2.  
  3. a = [
  4. "5 pounds cauliflower,",
  5. "cut into 1-inch florets (about 18 cups)",
  6. "2 large leeks,",
  7. "1 teaspoons salt",
  8. "3 cups of milk"
  9. ]
  10.  
  11. r = r"\d+(?= +cups?\b)"
  12.  
  13. def repl(m):
  14. return str(int(m.group(0)) + 1)
  15.  
  16. for s in a:
  17. print re.sub(r, repl, s)
Success #stdin #stdout 0.02s 6872KB
stdin
Standard input is empty
stdout
5 pounds cauliflower,
cut into 1-inch florets (about 19 cups)
2 large leeks,
1 teaspoons salt
4 cups of milk