Regex - An appropriate world containing only vowels or consonants

I have a problem with regex. I want to combine only these words, containing only vowels or consonants.

For example, I have lines like this:

aeyiuo 
aeYYuo 
qrcbk 
aeeeee 
normal 
Text 
extTT 

My regular expression should match: aeyiuo aeYYuo aeeeee

I don’t know why my expression doesn’t work. ^[aeyiuo]*|[^aeyiuo]*$ To test my regular expression, I use online parsers: http://www.regexr.com/ or http://regexpal.com/

If someone can explain my mistake to me, I would be very grateful.

+3
source share
6 answers

, [].
? ! [aeiouy].
, [aeiouy]+.
^[aeiouy]+$.
, i, . m, ^ $ . g, , .

-

+12

, ?

^[aeyiuo]+$

^[^aeyiuo]+$ .

. .

+1

aeiyou : \b[aeiyou]+\b.

( char) : \b[^\b\saeiyou]+\b

, : \b[aeiyou]+\b|\b[^\b\saeiyou]+\b

: aeyiuo aeYYuo qrcbk aeeeee

qrcbk, .

, ...

0

, ^[aeyiuo]* [^aeyiuo]*$ ( $ ^ ).

:

  • :

    ^([aeyiuo]*|[^aeyiuo]*)$

  • ^ $

    ^[aeyiuo]*$|^[^aeyiuo]*$

0

if ([^ aeiou])//False, ([^ b-df-hj-np-tv-z])//False,

0

: ^([^aeiouyAEIOUY0-9\W]+)$|^([aeiouyAEIOUY]+)$

:, ^ ([^ , , non-word-character \W) ] + $ |, ^ , + $

any = D


:

: ([aeiouyAEIOUY]+)
: ([^aeiouyAEIOUY0-9\W]+)
: ^([aeiouyAEIOUY]+)$
: ^([^aeiouyAEIOUY0-9\W]+)$

, , :
: (^([^aeiouyAEIOUY0-9\W]+)$|^([aeiouyAEIOUY]+))$)

:

, y, : (y(?=[aeiouAEIOU]))|([^aeiouAEIOU0-9\W])

0

Source: https://habr.com/ru/post/1689666/


All Articles