I need to cut short words (up to 2 characters), but leave the numbers. I do this:
/\b([а-я]{0,2})\b/u az /\b([а-я]{0,2})\b/u + preg_replace.
How do I set this regular season exceptions?
Type kg, cm, etc.
I need to cut short words (up to 2 characters), but leave the numbers. I do this:
/\b([а-я]{0,2})\b/u az /\b([а-я]{0,2})\b/u + preg_replace.
How do I set this regular season exceptions?
Type kg, cm, etc.
Use negative lookahead for example:
/\b(?!кг|см)([а-яё]{0,2})\b/ui Test https://regex101.com/r/IvpGWQ/1
PS Capture group can be removed https://regex101.com/r/IvpGWQ/2
Source: https://ru.stackoverflow.com/questions/607714/
All Articles