Progruzzle & Colf

Ruby, 44 43 40 + 1 = 41 bytes

+1 byte for -p flag. Takes space-separated input on STDIN.
-1 byte thanks to Martin Ender
-2 bytes thanks to histocrat

sub /([aeiou]+([^aeiou]*)){,2} \g<2>/,""

Try it online!

GNU sed, 39 37 + 1 = 38 bytes

+1 byte for -E flag. Takes space-separated input on STDIN.
-1 byte thanks to Martin Ender

s/([aeiou]+[^aeiou]*){,2} [^aeiou]*//

Try it online!

Not posting this as a separate answer because it is literally the same solution.


MATL, 31 30 bytes

t13Y2XJmFwhdl=fql_):)itJmYsg)h

Try it Online

Explanation

t       % Implicitly grab the input and duplicate it
13Y2    % Push the string literal 'aeiouAEIOU'
XJ      % Store this in clipboard J for later use
m       % Check which characters from the input are vowels (true for vowel)
Fwh     % Prepend FALSE to this logical array
dl=     % Compute the difference and find where we went from not-vowel to vowel
f       % Find the indices of these transitions
q       % Subtract 1 to get the location of the last consonant in each transition
l_)     % Get the next-to-last one of these
:)      % Grab the first string up to this location

% Now for the second component!

it      % Explicitly grab the input and duplicate
J       % Retrieve the string literal 'aeiouAEIOU' from clipboard J
m       % Find where the vowels are (true for vowel)
Ys      % Compute the cumulative sum along the array. The result will be 0
        % for all characters before the first vowel and non-zero after
g)      % Convert to logical and use this as an index so any characters
        % after the first value are retrieved

% Now to combine them

h       % Horizontally concatenate the first and second pieces together
        % Implicitly display the result

JavaScript (ES6), 81 73 72 bytes

Saved 8 bytes thanks to @Jordan, 1 thanks to @DavidConrad

a=>b=>a.match(/.*?(?=(?:[aeiou]+[^aeiou]*){1,2}$)/)+b.match(/[aeiou].*/)

Even though .match returns an array, array+array returns a string with the contents of the arrays concatenated (i.e. [0]+[1] returns "01").

Test snippet

f=a=>b=>console.log(a,"+",b,"=",a.match(/.*?(?=(?:[aeiou]+[^aeiou]*){1,2}$)/)+b.match(/[aeiou].*/))
f("brad")("angelina")
f("britain")("exit")
f("ben")("jennifer")
f("brangelina")("exit")
f("bill")("hillary")
f("angelina")("brad")
f("programming")("puzzle")
f("code")("golf")
f("progruzzle")("colf")
f("out")("go")
<input id=A value="super">
<input id=B value="chafouin">
<button onclick="f(A.value)(B.value)">Run</button>

Jordan's excellent Ruby solution would be 53 bytes in JS:

x=>x.replace(/([aeiou]+[^aeiou]*){1,2} [^aeiou]*/,"")

Tags:

Code Golf