digitalecartoons Posted November 7, 2007 Share Posted November 7, 2007 So how does that work exactly with preg_replace? Is there some kind of order? Lets take part of this text as string: "occurrence of \r\n into TWO line break" so when using: $message = preg_replace('~\r\n|\r|\n~', "\r\n", $message); to turn things into proper \r\n newline codes it first searches for \r\n, making it \r\n so it would remain: "occurrence of \r\n into TWO line break" then it would replace \r for \r\n, making it "occurrence of \r\n\n into TWO line break" finally it would replace \n for \r\n making it "occurrence of \r\r\n\r\n into TWO line break" Thats the way I see it , but it probably doesn't work that way with preg_replace and those 3 options seperated by an OR character? Quote Link to comment https://forums.phpfreaks.com/topic/76302-preg-replace-and-or/ Share on other sites More sharing options...
btherl Posted November 7, 2007 Share Posted November 7, 2007 regexps don't replace things that are already replaced. So the answer is no. Quote Link to comment https://forums.phpfreaks.com/topic/76302-preg-replace-and-or/#findComment-386451 Share on other sites More sharing options...
digitalecartoons Posted November 7, 2007 Author Share Posted November 7, 2007 But so it first searches for the 1st part \r\n then for the 2nd and finaly 3rd? I mean when there are 3 OR options a|b|c it first does a, then b, then c in that order? Quote Link to comment https://forums.phpfreaks.com/topic/76302-preg-replace-and-or/#findComment-386458 Share on other sites More sharing options...
btherl Posted November 7, 2007 Share Posted November 7, 2007 Yes it does. Try it and you'll see Quote Link to comment https://forums.phpfreaks.com/topic/76302-preg-replace-and-or/#findComment-386549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.