I'm just trying to figure out the regex to find any ampersands that aren't immediately preceded and followed by a space. For example, it would find "asdf&asdf" and "asdf& asdf" but not "asdf & asdf"
This will be used in a preg_replace to add spaces before and after. (If you're wondering, the problem is that I'm stuck with a WYSIWYG that has a bug where it strips spaces on both sides of ampersands, and I need to manually add them back after the fact). Thoughts?
(\S&\S|\s&\S|\S&\s)
OR
OR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With