PHP100 2019-03-27
代码如下:
< ?php //字符串 $string = "Name: {Name}< br>\nEmail: {Email}< br>\nAddress: {Address}< br>\n"; //模式 $patterns =array( "/{Address}/", "/{Name}/", "/{Email}/" ); //替换字串 $replacements = array ( "No.5, Wilson St., New York, U.S.A", "Thomas Ching", "[email protected]", ); //输出模式替换结果 print preg_replace($patterns, $replacements, $string); ?>
代码如下:
public static String PregReplace(this String input, string[] pattern, string[] replacements) { if (replacements.Length != pattern.Length) throw new ArgumentException("Replacement and Pattern Arrays must be balanced"); for (var i = 0; i < pattern.Length; i++) { input = Regex.Replace(input, pattern[i], replacements[i]); } return input; }
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh