Preg_replace not working
-
Hi,
Is there any reason why preg_replace should yield different results if run on an online test tool like https://regexr.com/ as opposed to running it in the wordpress context.
When this the following is run in the wordpress context, it finds a match and does the replacement, but not when run on two online regex tools.
The syntax is
return preg_replace('/\.mp3(?!\?name)(?!"])/', '.mp3?name=[current_user]', $content );
The string to search is:
‘[html5_audio src=”https://s3.amazonaws.com/sfs-premium/collection/Rider+Aids/Seat+Aids+and+Feel/Learning+How+to+Stop+Driving+with+Your+Seat/686-Learning-to-Stop-Driving-with-Your-Seat.mp3″%5D’Running the expression on the online tool, yields:
[html5_audio src=”https://s3.amazonaws.com/sfs-premium/collection/Rider+Aids/Seat+Aids+and+Feel/Learning+How+to+Stop+Driving+with+Your+Seat/686-Learning-to-Stop-Driving-with-Your-Seat.mp3″%5Dwhile run in the wordpress environment yields:
[html5_audio src=”https://s3.amazonaws.com/sfs-premium/collection/Rider+Aids/Seat+Aids+and+Feel/Learning+How+to+Stop+Driving+with+Your+Seat/686-Learning-to-Stop-Driving-with-Your-Seat.mp3?name=%5Bcurrent_user%5D”%5DDoes wordpress add chars causing the opposite results?
Any help will be appreciated.
Dion
- The topic ‘Preg_replace not working’ is closed to new replies.