aQ Posted October 27, 2007 Share Posted October 27, 2007 Hello there! I'm trying to get some regexp working, but I haven't done this before, so I need some help. I have a text-document with a lot of links I want to get rid of. The syntax of the links are "http://www.yr.no/stad/Noreg/*SOMETHING*/*SOMETHING*/*SOMETHING*/varsel.xml". "*SOMETHING*" is different from link to link. The links does also contain Scandinavian letters like Æ Ø and Å (æ ø and å). At the moment, I've got this, but it doesn't work: $file = file_get_contents("viktigestader.txt"); $find = array("http:\/\/www.yr.no\/stad\/Noreg\/.+\/.+\/.+\/varsel.xml"); $replace = array(""); $done = preg_replace($find, $replace, $file); print $done; I hope you could help me out. Quote Link to comment https://forums.phpfreaks.com/topic/75024-solved-regexp-help/ Share on other sites More sharing options...
aQ Posted October 27, 2007 Author Share Posted October 27, 2007 I finally fixed it using this line: #(http:\/\/www.yr.no\/stad\/Noreg\/[a-zA-Z0-9æøåÆØÅ]+\/[a-zA-Z0-9æøåÆØÅ]+\/[a-zA-Z0-9æøåÆØÅ]+\/varsel.xml)# Quote Link to comment https://forums.phpfreaks.com/topic/75024-solved-regexp-help/#findComment-379372 Share on other sites More sharing options...
effigy Posted October 29, 2007 Share Posted October 29, 2007 1. Since you've changed the delimiter there is no need to escape /. 2. If you want a literal period, escape it: \.. 3. . should have worked because it matches everything except a new line. Quote Link to comment https://forums.phpfreaks.com/topic/75024-solved-regexp-help/#findComment-380342 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.