Undrium Posted May 16, 2011 Share Posted May 16, 2011 I have this: #(?<=\n|^|\s|\() I also want to squeeze in that it's okey if it is preceded by a newline, how do I write that? Quote Link to comment Share on other sites More sharing options...
requinix Posted May 16, 2011 Share Posted May 16, 2011 If what's preceded by a newline? What you posted is just a fragment of a regular expression. Quote Link to comment Share on other sites More sharing options...
Undrium Posted May 16, 2011 Author Share Posted May 16, 2011 Sorry I wasn't clear enough, I am writing an assertion and this is how far I have come. I want to preg_replace a word if it does have a whitespace, is the start of string or a newline is preceded. Problem is I do not know how to write newline in the assertion. I know that \s for instance means any whitespace so I have that sorted out. Quote Link to comment Share on other sites More sharing options...
requinix Posted May 16, 2011 Share Posted May 16, 2011 Well, "whitespace" already includes newlines, so (? Quote Link to comment Share on other sites More sharing options...
Undrium Posted May 17, 2011 Author Share Posted May 17, 2011 It's not doing the trick, though. Sat some hours yesterday with this problem: $s = preg_replace('#(?<=^|\s|\()(http://[^\s\)]+)#', '[url=$1]$1[/url]', $data); Everything works fine until a newline occurs, if the URL is located after a newline it won't activate. However if I make a space after the newline it will replace. Also it works if the URL is at the start of a string. This will work: Some text http://www.address.com This won't work: Some text http://www.address.com Quote Link to comment Share on other sites More sharing options...
requinix Posted May 17, 2011 Share Posted May 17, 2011 Works fine for me. echo preg_replace('#(? What's the rest of your code? Quote Link to comment Share on other sites More sharing options...
Undrium Posted May 17, 2011 Author Share Posted May 17, 2011 Yeah, you are right, it is working. I turned off all my other processing of the text and it turned out to be my antiinjectfunction screwing it up. Thanks for the second view. Quote Link to comment 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.