Reputation: 45
I want to find one or more cyrillic characters(а-я) within a string. So far i manage to find the character wherever it is except for the start of the string.
Expression that i'am using -> ^[\p{L}\d\s\-](.*[а-яА-Я].*)+$
Upvotes: 2
Views: 1649
Reputation: 627110
You can use
^\P{Cyrillic}*\p{Cyrillic}.*
See the regex demo.
If you want to only deal with Russian chars, you can replace \p{Cyrillic}
with [а-яёА-ЯЁ]
and \P{Cyrillic}
with [^а-яёА-ЯЁ]
.
Details:
^
- start of string\P{Cyrillic}*
- zero or more chars other than Cyrillic\p{Cyrillic}
- a Cyrillic char.*
- zero or more chars other than line break chars as many as possible.To match multiline strings, add (?s)
at the start, or replace .
with a [\w\W]
workaround construct.
Upvotes: 3