3 Years
Discussion Span
Last Post by n21115

See the PHP preg_replace Manual for the full synopsis of that function. But in a nutshell, the code you've provided uses a regular expression to delete any instance within $plain_text of a new-line character which is followed by a null character (end-of-string), which in turn is followed by any amount of characters and another new line character.

Edited by Assembly Guy


thanks for your reply,
please tell me process undergone in "/\x13\x00*$/", if possible explain separately !


EDIT: It's not looking for a new line character, it's looking for a DC3 character.

It's what's known as a regular expression.

Basically, the two /s merely indicate the start and end of the regex. Just ignore them for now. \x13 is an escape sequence, basically meaning that instead of trying to find x13, PHP should try and find the character with the ASCII code of 13 (in hex). The same principle applies for the \x00 part - it's not trying to find \ and x00, but instead the character with the ASCII value of 0. The asterisk (*) means 'zero or more characters'. The '$' just means 'end of the line'.

So when this regular expression is put together, PHP will be searching for the entire pattern, in that order. I'm not very good at explaining this in an understandable manner, maybe someone else can clarify it. Or you might prefer to read about regular expressions on the web..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.