Viper Viper - 1 year ago 122
PHP Question

Regex PHP - Starts with and ends with

I've following problem: I'm trying to replace every occurrence of a string that starts with % and also ends % with, in the middle of the precentage symbols there should be alphanumerical chars. and brackets () allowed.
This is what I currently have:


Answer Source

^%[a-zA-Z0-9()]+%$ would work fine if your percent signs start and end the line. However, I assume this is not the case.

^ means the beginning of a line, $ means the end of a line. I assume you would want just: %[a-zA-Z0-9()]+%

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download