A string is called beautiful if its first and last characters are the same.
Given a string S, determine whether it is beautiful.
Input Format
A single line containing the string S.
Output Format
Print:
"Yes" if the string is beautiful. "No" otherwise.
Examples
Input:
abca
Output: Yes
Input:
hello
Output:
No
Input:
z
Output:
Yes
Explanation "abca" → first = 'a', last = 'a' → Beautiful "hello" → first = 'h', last = 'o' → Not Beautiful "z" → first = last = 'z' → Beautiful
Instead of writing normal string comparison logic, implement the solution using a regular expression.
The program should print:
true if the string matches the required pattern. false otherwise.
Hint: Use a capturing group for the first character and ensure the last character matches the captured character.
Example regex pattern:
^(.).*\1$
Note: Since the pattern above does not match single-character strings, you may modify it appropriately (or handle that case separately) depending on the regex engine used.
1 ≤ |S| ≤ 10^5
S consists only of English letters (a-z, A-Z).
Phonepay • Pending