HackerRank-Python/Regex
Prepare > Regex > Repetitions > Matching Ending Items
stem_sw
2023. 11. 8. 19:55
Matching Ending Items | HackerRank
Match the end of the string using the $ boundary matcher.
www.hackerrank.com
문제
Task
Write a RegEx to match a test string, S, under the following conditions:
- S should consist of only lowercase and uppercase letters (no numbers or symbols).
- S should end in s.
=> S는 대소문자로만 이뤄져있고, s로 끝난다
코드
Regex_Pattern = r'^[a-zA-Z]*s$' # Do not delete 'r'.
import re
print(str(bool(re.search(Regex_Pattern, input()))).lower())
노트
$ 문자열의 종료
The $ boundary matcher matches an occurrence of a character/character class/group at the end of a line.
- 문자, 문자클래스, 그룹의 줄 끝을 알리는 메타문자