Просто ( -p
or <!-- snippet demo: -->
<input list=l oninput=console.log(f(this.value))>
<datalist id=l><option value=Land>
<option value=Moonlight>
<option value=queueing>
<option value="This isn't a single word.">
<option value="It's fun to play golf">
<option value=Ooo>
<option value="I'm okay.">
<option value="Hmm, no. There will be at least one vowel, but it can be anywhere.">
<option value="Why is y a vowel?">
) PCRE без учета регистра Рзаменить
f=
x=>(y=/.*?[aeiouy]+/i.exec(x)+' ')+y+x
the beginning
x=>(y=/.*?[aeiouy]+/i.exec(x)+' ')+y+x
zero or more characters (lazy)
$argn
one or more vowels
с
-R
the entire match thrice with spaces inbetween
Версия без RegEx, 43 байта
i
echo "This isn't a single word." | php -nR 'echo preg_filter(~ðэÎÐı└ñ×ÜûÉèåóÈÍðû,~█╬▀█╬▀█¤,$argn);'
lowercase
echo preg_filter("/^(.*?[aeiouy]+)/i","$1 $1 $0",$argn);
echo preg_filter(~ðэÎÐı└ñ×ÜûÉèåóÈÍðû,~█╬▀█╬▀█¤,$argn); # Encoded
append a space
->s{(s[/.*?[aeiouy]+/i]+' ')*2+s}
which letters are vowels
$args-replace"^.*?[aeiouy]+",(,'$&'*3)
vowels that are followed by a non-vowel
g
index of first one
@echo off
set/ps=
set v=aeiouy
set g=c
set t=
:l
call set w=%%v:%s:~,1%=%%
if %v%==%w% goto %g%
set g=o
:c
set t=%t%%s:~,1%
set s=%s:~1%
goto l
:o
echo %t% %t% %t%%s%
… i`^.*?[aeiouy]+
$& $& $&
примените следующую неявную функцию со строкой в качестве правого аргумента и указанным выше индексом в качестве левого аргумента
let f=
x=>x.replace(/.*?[aeiouy]+/i,'$& $& $&')
test=`Land
La La Land
Moonlight
Moo Moo Moonlight
queueing
queuei queuei queueing
This isn't a single word.
Thi Thi This isn't a single word.
It's fun to play golf
I I It's fun to play golf
Ooo
Ooo Ooo Ooo
I'm okay
I I I'm okay
Hmm, no. There will be at least one vowel, but it can be anywhere.
Hmm, no Hmm, no Hmm, no. There will be at least one vowel, but it can be anywhere.`
test.split(`\n\n`).forEach(z=>{
var [i,k]=z.split(`\n`),x=f(i);
console.log(k==x ? 'OK':'KO',i+'\n'+x);
})
that many characters taken from the string
x=>x.replace(/.*?[aeiouy]+/i,'$& $& $&')
followed by
import re;lambda x:re.sub('(.*?[aeiouy]+)',r'\1 \1 \1',x,1,2)
that many characters taken from the string
;⁶e€Øyw⁵ḣ@;⁶Ȯ; - Main link: string s
⁶ - space character
; - concatenate to s (for all vowel edge case)
Øy - vowels + y yield
e€ - exists in? for €ach (gives a list of isVowel identifiers)
⁵ - 10
w - index of first sublist (with implicit decimalisation of 10 to [1,0])
ḣ@ - head with reversed @rguments (start of word up to & including vowel group)
⁶ - space character
; - concatenate (start of word up to & including vowel group plus a space)
Ȯ - print and yield (hence a full program...
- ...the alternative ẋ2 repeats instead in order to return the result)
; - join with the input, s
- implicit print (of the second repetition and input string)
followed by
;⁶e€Øyw⁵ḣ@;⁶ẋ2;
the string