mysterbx Posted February 26, 2008 Share Posted February 26, 2008 Hey hey, can I somehow find everything that goes after word synopsis until \n? I tried \N but it doesnt work on my server Something like this (but not with \N with some other regex formula) preg_match_all("#(synopsis)(\:| \:|\: | \: |)([\N){30,999})#ise", trim(strip_tags(html_entity_decode($r2))), $description); Quote Link to comment Share on other sites More sharing options...
freenity Posted February 26, 2008 Share Posted February 26, 2008 Try this? preg_match("synopsis[.]*") Quote Link to comment Share on other sites More sharing options...
Orio Posted February 26, 2008 Share Posted February 26, 2008 Just drop the 's' modifier. This way the dot metacharater won't match newlines. You also don't really need the 'e' modifier as it is only used in preg_replace()... preg_match_all("#synopsis(.*)#i", trim(strip_tags(html_entity_decode($r2))), $description); Orio. Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 26, 2008 Author Share Posted February 26, 2008 thanks this code,it works, but how can I replace lines that have more than one \n into only one line... example: text mytext .. something more Output text mytext .. something more Quote Link to comment Share on other sites More sharing options...
effigy Posted February 26, 2008 Share Posted February 26, 2008 preg_replace('/\n+/', "\n", $string); Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 27, 2008 Author Share Posted February 27, 2008 doesnt work... [RS.Com] - Ritual (2001) Ritual (2001) Plot Dr. Alice Dodgson gets her medical license revoked after the death of one patient. She's facing the possibility of not get any job when she accepts to be the nurse for one young man who suffers of cephallitis called Wesley Claybourne. Aside from the sickness he's suffering Wesley believes he has been "touched" by some voodoo cult. While she stays in Jamaica, Dr. Dodgson will feel uncomfortable as she discovers that voodoo is not only a "state of mind" and could be a real threat to her life and Wesley's. She'll have to discover why she and her patient are targets of the voodoo curse. Also Known As Revelation (USA) (working title) Tales from the Crypt Presents: Revelation (USA) Tales from the Crypt Presents: Voodoo (Philippines: English title) IMDb Code: P.S. try highliting the text, there are a lot of spaces (\s) Quote Link to comment Share on other sites More sharing options...
effigy Posted February 27, 2008 Share Posted February 27, 2008 preg_replace('/^\s*$/m', '', $data); Quote Link to comment Share on other sites More sharing options...
mysterbx Posted February 28, 2008 Author Share Posted February 28, 2008 still something is wrong... What about this: if line contains only one \n then replace it with nothing, but if the line has more than two \n then replace it with only one \n possible? Quote Link to comment Share on other sites More sharing options...
effigy Posted February 28, 2008 Share Posted February 28, 2008 <pre> <?php $data = <<<DATA text mytext .. something more DATA; echo preg_replace('/^\s*\n/m', '', $data); ?> </pre> yields: text mytext .. something more 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.