简体   繁体   中英

Changing preg_match condition

My function is changing $word_one (je/que je in j'/que j'), if $word_two begins with a vowel.

function FrenchCompoundTenses($word_one, $word_two) {
if(preg_match('~(.*)\bje$~ui', $word_one, $m) && preg_match('~^[aeéiou]~ui>', $word_two)) 
    return "<td class=\"text-right text-muted\">{$m[1]}j'</td>" . $word_two;               
else 
    return "<td class=\"text-right text-muted\">". $word_one ."</td>" . $word_two;
}  

For a similar function I have to change this part:

&& preg_match('~^[aeéiou]~ui>', $word_two)

It should worked, if $word_two begin with HTML code <u> or </td><td> and then a vowel is following.( [aeéiou] )

EDIT: $word_one comes from an array with pronoun and $word_two comes from a 2-dimensional array. $word_two are in this case two words.

example:

 $word_one= 'je' +   $word_two='aime'  =  j'aime 
 $word_one= 'tu' +   $word_two='aimes' = tu aimes 

desired output with this function:

 $word_one= 'je' +   $word_two='<u>aime' = j'aime (with html code between)
 $word_one= 'je' +   $word_two='</td><td>aime' = j'aime (with html code between)

&& preg_match('~^h?(?:[aæàâeéèêëiîïoôœuûù]|y(?![aæàâeéèêëiîïoôœuûù]))~ui', strip_tags($word_two)) should solve the problem.

(I added an optional h at the begining since h is a silent h in french. I added too several accented vowels) and the y when not followed by another vowel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM