import re
ju = input("") # 123456-1234567
print(re.sub("d{7}","1******", ju))
I don't know how to put it in order to cut it to 6 digits and get the front seat...ㅜ<
python
It is simple to use grouping when compiling regular expressions.
If you look at the example, you'll understand it simply.
I randomly opened the code...
import re
Example sentence = "123456 - 1234567"
Pattern = re.compile()
r"(\d{6} - \d{1})\d{6}"
)
print(
Pattern.sub("\g<1>****", example sentence)
) # Result: 123456 - 1****
Among the codes, brackets (...) in the above expression and "\g" in the following expression are the grouping associated grammar.
Another way to write it,
import re
Example sentence = "123456 - 1234567"
Pattern = re.compile()
r"(\d{6}) - (\d{1})\d{6}"
)
print(
Pattern.sub("\g<1> - \g<2>****", example sentence)
) # Result: 123456 - 1****
© 2024 OneMinuteCode. All rights reserved.