I am not very good at regular expressions so i have hacked a solution to ignore whitespaces or new lines
here is my string which i am trying to find a match
$str = 'name="something"> function
(para
m)';
The string may have line breaks or whitespaces anywhere. Please note that i do not want a implementation to which includes string replacing on \n or \r or " ", as my real string is a PDF file containing human readable text.
My current solution is to wrap each character in (MY CHAR HERE)(\s)* as you can imagine my regex will be rather large for a big search string ie
(n)(\s)*(a)(\s)*(m)(\s)*(e)(\s)*(=)(\s)*(")(\s)*(s)(\s)*(o)(\s)*(m)(\s)*(e)(\s)*(t)(\s)*
etc..............
Is there a simplier/cleaner solution for this?
My end goal is to do preg_replace
so hopefully something like this
$pattern = ''; //My new pattern here
$str = 'name="something"> function
(para
m)';
$replace = 'name="something"> different function(param1, param2){} function(param)';
echo preg_replace($pattern, $replace, $str);
n\s*a\s*m\s*e\s*=\s*"\s*s\s*o\s*m\s*e\s*t\s*