note 127118 added to function.mb-ereg-replace

From: Date: Thu, 19 May 2022 18:35:18 +0000
Subject: note 127118 added to function.mb-ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-218505@lists.php.net to get a copy of this message
Notations to reference captures in the replacement string: <?php // (1) \\number notation: (1 to 9, not greater than 9) echo mb_ereg_replace('(\S*) (\S*) (\S*)', '\\1 jam, \\2 juice, \\3 squash', 'apple orange lemon').'<br>'; // apple jam, orange juice, lemon squash // (2) \k<number> notation: (also greater than 9) (also as \k'number') echo mb_ereg_replace('(\S*) (\S*) (\S*)', '\k<1> jam, \k<2> juice, \k<3> squash', 'apple orange lemon').'<br>'; // (same as above) // (3) \k<word> notation: (also as \k'word') echo mb_ereg_replace('(?<word1>\S*) (?<word2>\S*) (?<word3>\S*)', '\k<word1> jam, \k<word2> juice, \k<word3> squash', 'apple orange lemon').'<br>'; // (same as above) // Note non-named-subpatterns like "(\S*)" should not be used with named-subpatterns like "(?<word>..)" because non-named-subpatterns cannot be captured when named-subpatterns exist. ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.47 (proxied: 153.197.125.206) ---- Manual Page -- https://php.net/manual/en/function.mb-ereg-replace.php Edit -- https://main.php.net/note/edit/127118 Del: integrated -- https://main.php.net/note/delete/127118/integrated Del: useless -- https://main.php.net/note/delete/127118/useless Del: bad code -- https://main.php.net/note/delete/127118/bad+code Del: spam -- https://main.php.net/note/delete/127118/spam Del: non-english -- https://main.php.net/note/delete/127118/non-english Del: in docs -- https://main.php.net/note/delete/127118/in+docs Del: other reasons-- https://main.php.net/note/delete/127118 Reject -- https://main.php.net/note/reject/127118 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218505) next »