Try :
preg_replace('/(.*)[F]{2}$/','$1}"','#define FWTE_BLACK "{000000FF');
Based on your comment this is the update:
echo preg_replace('/(.*)[F]{2}([\n\r])+/','$1}"$2',$myString);
Question
I have a problem in preg_replace.
I have a text file which includes:
#define FWTE_BLACK "{000000FF
#define FWTE_TEST "{006600FF
...
The complete text is here : https://eval.in/133942
I would like to replace the ending FF
on each line to }"
Like this :
#define FWTE_BLACK "{000000}"
#define FWTE_TEST "{006600}"
...
Solution 4
Try :
preg_replace('/(.*)[F]{2}$/','$1}"','#define FWTE_BLACK "{000000FF');
Based on your comment this is the update:
echo preg_replace('/(.*)[F]{2}([\n\r])+/','$1}"$2',$myString);
OTHER TIPS
You can try this:
preg_replace('/FF$/m', '}"', $file_string);
Try this:
$content = preg_replace('#FF$#', '}"' $content);
/\w{2}$/
<?php
$str = "#define FWTE_TEST \"{006600FF";
$pattern = '/\w{2}$/';
$replacement = '}"';
echo preg_replace($pattern, $replacement, $str);
?>
#define FWTE_TEST "{006600}"
Hope this help you!