preg_replace vs preg_match

if you are trying to replace a string, the pre_replace can serve as its own ‘foreach’ loop. so you don’t have to worry about that part, especially if the replacement string is always the same. I am not certain if using the builtin loop will do anything to speed up the function or not.

using if you were looking for specific strings, a str_replace, str_ireplace are much faster!

for example if you re ALWAYS looking for a string containing 30 “_” characters, you could do that with a str_replace.

Consider checking your reggae logic as well. For example:
“/^-(.)Original Message(.)-/i”
will select a string that begins with -(0- infinite times), good so far.
followed any number of any non newline characters ( which means essentially the only stop would be a tab or a break or something). This selection will be kind of broad, and thus it will never even get to look for :“Original Message”, let along the other string of characters of undefined length that follows. :confused: