Text Processing #1: Hyphenation Background

This is the first part of a 3-hole golf course on text processing.
The over-arching idea is that if you take an input text and pipe it through the solutions to all three challenges (with a small amount of glue code), it will spit out a beautifully formatted paragraph.
In this first challenge, your task is a hyphenate a piece of text using given hyphenation patterns.

Input

Your program shall take two string inputs: a piece of text and a list of hyphenation patterns.
The first input is simply a non-empty string of printable ASCII characters and spaces; it will not contain line breaks or tildes ~.
The second input is a comma-delimited list of words, which consist of tilde-delimited syllables of lowercase ASCII characters.
An example is ex~cel~lent,pro~gram~ming,abil~i~ties.

Output

Your program shall modify the first input in the following way.
Any word (maximal substring of alphabetical ASCII characters) whose hyphenated lowercase version is found in the second input shall be replaced by that hyphenated version, but its case shall be preserved.
With the above example list, if the text contains the word Excellent, it shall be replaced by Ex~cel~lent; however, Excellently shall not be modified.
Your output shall be this modified string.

Detailed Rules and Scoring

You can assume the following about the inputs:


The first input contains no tildes, and no leading, trailing or repeated spaces. It is not empty.
The second input contains at least one word, and each word in it contains at least two syllables. Each syllable is non-empty.
The second input does not contain a word that occurs as a syllable in another word.


You can change the order of the two inputs, if desired, and optionally add one trailing newline to the output.

You can write a function or a full program.
The lowest byte count wins, and standard loopholes are disallowed.

Test Cases

These are listed in the format 1st input [newline] 2nd input [newline] output.

Excellent programming abilities, you work excellently!
ex~cel~lent,pro~gram~ming,abil~i~ties
Ex~cel~lent pro~gram~ming abil~i~ties, you work excellently!

Superman (sometimes incorrectly spelled "Super-man") is super #&amp;%@ing strong.
su~per,some~times,in~cor~rectly,spell~ing
Superman (some~times in~cor~rectly spelled "Su~per-man") is su~per #&amp;%@ing strong.

IncONsISTent caPItalizATIon!
in~con~sis~tent,cap~i~tal~iza~tion
In~cON~sIS~Tent caP~I~tal~izA~TIon!

Such short words.
awk~ward
Such short words.

Digits123 are456cool789.
dig~its,dig~i~tal,are~cool
Dig~its123 are456cool789.

magic magic
ma~gic
ma~gic ma~gic


Any possible hyphenation error in this challenge is due to this hyphenation tool.
Retina, 88 bytes

+is`(?&lt;![a-z~])([a-z~]+)(?=([a-z]+)+[^a-z~].*(?&lt;=[\n,]\1(?(2)!)(?&lt;-2&gt;~\2)+[\n,]))
$1~
\n.*
&lt;empty&gt;


For counting purposes, each line goes into a separate file, \n are replaced with actual newline characters and &lt;empty&gt; is an empty file. For convenience, you can run the above code from a single file (where &lt;empty&gt; is an empty line) if you use the -s interpreter flag.