PHP String: remove "\newline" after "\end{Figure}" -


i've php string of around 4000 chars; if anywhere in php string $input1, $input2 or $input3 identified, want replace same $output string. in summary want remove "\newline" after "\end{figure}"

$input1 = "\end{figure}\newline"; $input2 = "\end{figure} \newline"; $input3 = "\end{figure}\newline "  required output:  $output = "\end{figure}";  

can please suggest how achieve required output?

your question not clear, perhaps looking for:

$result = preg_replace('~\\\end\{figure}\k( )?\\\newline(?(1)| )~', '', $text); 

pattern details:

~                # pattern delimiter \\\              # backslash (must double escaped inside quotes) end\{figure} \k               # reset begining of match ( )?             # optional capturing group n°1 \\\newline (?(1)| )         # if capturing group n°1 exists there nothing else space  ~ 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -