Re: [PHP] strip out too many newlines

2005-08-04 Thread Marco Tabini
On 8/4/05 10:56 AM, "Sebastian" <[EMAIL PROTECTED]> wrote: > that works for my orginal request, but i found something else: > > $string = '[quote=xx]foo[/quote]\nmore text\r\n\r\n\r\n\r\nmore text'; > Try removing double-instances of \r\n (or \n) before running the regex. Marco > now if they

Re: [PHP] strip out too many newlines

2005-08-04 Thread Sebastian
that works for my orginal request, but i found something else: $string = '[quote=xx]foo[/quote]\nmore text\r\n\r\n\r\n\r\nmore text'; now if they enter more carriage returns i get the results from above. its no big deal, but you always have someone trying to 'break' the system. thanks, i real

Re: [PHP] strip out too many newlines

2005-08-04 Thread Marco Tabini
Try changing the \n* patterns to (?:\r?\n)* Cheers, Marco -- BeebleX - The PHP Search Engine http://beeblex.com On 8/4/05 10:39 AM, "Sebastian" <[EMAIL PROTECTED]> wrote: >>> [quote=user] >>> foo >>> [/quote] >>> >>> >>> >>> more text... -- PHP General Mailing List (http://www.php.n

Re: [PHP] strip out too many newlines

2005-08-04 Thread Sebastian
thanx for the reply, but 1 problem. there is not only \n there are \r in the POST too (carriage returns) so a string can look like this: $string = '[quote=xx]\r\nfoo\r\n[/quote]\r\nmore text\r\n\r\n\r\n\r\n'; and your regexp will only catch if there is just \n any solution for \r\n in combinati

Re: [PHP] strip out too many newlines

2005-08-04 Thread Marco Tabini
Don't know much about the app you're writing, but does this do the trick for you? echo preg_replace ('! ( \[quote (?:=[^\]]*)? \] )# Capture the [quote=xxx] part

[PHP] strip out too many newlines

2005-08-04 Thread Sebastian
im working on a comment/forum app and when a user enters too many carriage returns i want to remove them before insert to db. example, user input: -snip- [quote=user] foo [/quote] more text... -snip- I to change to: [quote=user]foo[/quote] more text... i try this regexp: