$re = '/(\b[^,\v\s]+?,\s[^,\v\s]+?)((?:\s(?:and|or)\s)(\s?(?:above|across|after|at|around|before|behind|below|beside|between|by|down|during|for|from|in|inside|onto|of|off|on|out|through|to|under|up|with|other)\s)?(?:\w+)(?:[ \]\)\?\.\;\!\:]))/m';
$str = 'capital as the Trustee, in its sole judgment, shall think fit to advance from time to time out of such trust\'s other resources, whether for continuation or expansion or any other purpose; and the Trustee, in its sole discretion, may incorporate a part or all of said business (or any investment held in such trust) in one or more corporations, with whatever capital structure may be deemed appropriate, alone or with others, in any jurisdiction, or form partnerships in which such trust may be a general or limited partner, or form limited liability companies in which such trust may be a managing member or a non-managing member, or enter into joint ventures or associations with others on such terms as may be deemed appropriate, or enter into agreements respecting voting rights, management, incentive compensation, profit sharing, future sale or retention, all without obtaining authority from any court, and the Trustee, while acting in good faith, shall be free from any responsibility for losses arising in the prosecution of such business. Pig, trees and bogs for sale.
6.1.5 Borrowing Money. The power (i) to borrow money for the benefit of the trust from the Trustee individually or from others, upon any terms and conditions, (ii) to secure the payment of any amount so borrowed by mortgaging, pledging or otherwise encumbering any real or personal property, and (iii) to modify, renew or extend the time for payment of any obligation, secured or unsecured, payable by the trust, for any period or periods of time and upon any terms and conditions.
6.1.6 Lending Money. The power (i) to lend money to any person upon any terms and conditions, (ii) to modify, renew, or extend the time for payment of any obligation, secured or unsecured, payable to the trust for any period or periods of time and upon any terms and conditions, (iii) to foreclose as an incident to the collection of any obligation, any dee';
$subst = "$1,$2";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php