Skip to content

Commit 36632ea

Browse files
committed
Append regexp_examples/sub__get_initials__use_callback.py
1 parent 89f91b2 commit 36632ea

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = 'ipetrash'
5+
6+
7+
text = 'Иванов Иван Иванович'
8+
9+
replace_match = lambda x: '{} {}. {}.'.format(x[1], x[2][0], x[3][0])
10+
11+
import re
12+
new_text = re.sub(r'(\w+) (\w+) (\w+)', replace_match, text)
13+
print(new_text) # Иванов И. И.

0 commit comments

Comments
 (0)