I am having the darkest time figuring this out. I have function that that takes a string ( that is read from a DB then stored in a variable) and looks for a pattern match using a regex . pretty basic stuff. except that the regex always returns false.
In the process of testing I found that the expression works perfectly tested on a string that that is ‘hard coded’ within the script , as opposed to string brought in via the DB.
Whats weirder still is if I OUPUT the string to HTML, copy that output in to a variable in the script , and run that variable through the script it returns all matches as expected!
so it seems to me that the regex works ( when tested by evaluating a hardcoded test string)
And the patterns it looks for are within the data returned from the DB. ( as tested by outputting the DB data to HTML, and copy pasting that data from the View Source in to a variable and testing the regex with it). I even went to the mySQL control panel and copied the string directly from there and the regex once again performed as expected,
the only thing I can the raw string from the DB could be inserting invisible characters that are not rendered or outputted when echoed to HTML.
I would be much obliged if anyone could suggest how to test for these invisible characters or any suggestion as to why a regex would not work on a ‘raw’ string from a DB but apparently works perfectly on the SAME string when copy-pasted as part of the script