Return the `s` string with any of the string in the `prefixes` set striped from the left. Normalize and strip spaces. For example: >>> s = 'by AND for the Free Software Foundation' >>> strip_prefixes(s) == 'the Free Software Foundation' True
(s, prefixes=prefixes)
| 384 | |
| 385 | |
| 386 | def strip_prefixes(s, prefixes=prefixes): |
| 387 | """ |
| 388 | Return the `s` string with any of the string in the `prefixes` set |
| 389 | striped from the left. Normalize and strip spaces. |
| 390 | |
| 391 | For example: |
| 392 | >>> s = 'by AND for the Free Software Foundation' |
| 393 | >>> strip_prefixes(s) == 'the Free Software Foundation' |
| 394 | True |
| 395 | """ |
| 396 | s = s.split() |
| 397 | while s and s[0].lower().strip().strip('.,') in prefixes: |
| 398 | s = s[1:] |
| 399 | return ' '.join(s) |
| 400 | |
| 401 | |
| 402 | # set of suffixes that can be stripped from a name |