[英]Changing preg_match condition
My function is changing $word_one
(je/que je in j'/que j'), if $word_two
begins with a vowel. 如果$word_two
以元音开头,则我的函数将更改$word_one
(在j'/ que j'中为je / que je)。
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]
) 如果$word_two
以HTML代码<u>
或</td><td>
开头,然后是元音,则[aeéiou]
。( [aeéiou]
)
EDIT: $word_one
comes from an array with pronoun and $word_two
comes from a 2-dimensional array. 编辑: $word_one
来自代词数组,而$word_two
来自二维数组。 $word_two
are in this case two words. $word_two
在这种情况下是两个单词。
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. && preg_match('~^h?(?:[aæàâeéèêëiîïoôœuûù]|y(?![aæàâeéèêëiîïoôœuûù]))~ui', strip_tags($word_two))
应该可以解决此问题。
(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. (我在开头添加了一个可选的h
,因为h
在法语中是一个无声的h
。我添加了太多的重音元音)和y
在没有其他元音之后)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.