12 lines
288 B
Python
12 lines
288 B
Python
import re
|
|
|
|
|
|
class Solution:
|
|
def reversePrefix(self, word: str, ch: str) -> str:
|
|
match = re.search(rf"{ch}", word)
|
|
if match:
|
|
position = match.start()
|
|
return word[: position + 1][::-1] + word[position + 1 :]
|
|
else:
|
|
return word
|