GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — example-code-2e/04-text-byte/ramanujan.py at master · FerMatPy/example-code-2e Expand file tree/ Copy pathramanujan.pyMore file actions 21 lines (17 loc) · 695 Bytes / Copy pathramanujan.pyFile metadata and controls21 lines (17 loc) · 695 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # tag::RE_DEMO[] import re re_numbers_str = re.compile(r'\d+') # <1> re_words_str = re.compile(r'\w+') re_numbers_bytes = re.compile(rb'\d+') # <2> re_words_bytes = re.compile(rb'\w+') text_str = ("Ramanujan saw \u0be7\u0bed\u0be8\u0bef" # <3> " as 1729 = 1³ + 12³ = 9³ + 10³.") # <4> text_bytes = text_str.encode('utf_8') # <5> print(f'Text\n {text_str!r}') print('Numbers') print(' str :', re_numbers_str.findall(text_str)) # <6> print(' bytes:', re_numbers_bytes.findall(text_bytes)) # <7> print('Words') print(' str :', re_words_str.findall(text_str)) # <8> print(' bytes:', re_words_bytes.findall(text_bytes)) # <9> # end::RE_DEMO[] |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |