Restart mainsrv01 at midnight
mainsrv01 encountered error in apache at 21:30
To use regular expressions you need regularity. Can you point out what is regular in the two strings you have posted? I know they both include mainsrv01 but you have already pointed out that will not be regular.
I may not be reading enough into this, but every example you've given seems simple enough. Why don't you just str_replace() the asterisks with "censored".
In fact, don't even put the asterisks in there in the first place.
I think I'm failing to describe this properly or even see it clearly myself. I will get variables from an external function, which I need to edit before presenting. I know all of the texts, but I do not know some "parts" of it.
For example: Kill process * on server *
With *, I mean the original text can contain anything there, things I have no control over or knowledge about. But I do know that the other words will be there.
This is what I have created now:
PHP Code:
//From external function:
//Kill process apache on server mainsrv01
$result = preg_replace("/^Kill process (.*?) on server (.*?)$/","Kill process $removed on server $removed",$original_text);
//and
//From external function:
//mainsrv01 encountered error in apache at 21:30
$result = preg_replace("/^(.*?) encountered error in (.*?) at (.*?)$/","$removed encountered error in $2 at $3",$original_text);
This seems to be doing the trick so far...but may be really stupid to do this
Bookmarks