steveclondon Posted December 14, 2006 Share Posted December 14, 2006 Hi,I want to automatically strip out any email addresses and website links that users may enter into a form. Does anyone know of any good classes to do this, as I am sure I would just be reinventing the wheel if I start making the code for this. If not any ideas of the best way to go about it will be of great help. I would imagine that I would need to search for the @ symbol and www. then count the start of the word and end of the word and replace it with a space. I know how to tackle it that way using string replace etc but if there is a quicker or better way please let me know. Would preffer a class that already does this though. Link to comment https://forums.phpfreaks.com/topic/30643-take-out-emails-and-web-addresses-from-form-information/ Share on other sites More sharing options...
zq29 Posted December 14, 2006 Share Posted December 14, 2006 You could do it like this...[code]<?php//UNTESTED$p = array("/\b(http|https|ftp):\/\/((\w+\.)+)\w{2,}(\/?)\b/i","/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i");preg_replace($p,"",$subject);?>[/code] Link to comment https://forums.phpfreaks.com/topic/30643-take-out-emails-and-web-addresses-from-form-information/#findComment-141299 Share on other sites More sharing options...
steveclondon Posted December 15, 2006 Author Share Posted December 15, 2006 Brillant, worked a treat Link to comment https://forums.phpfreaks.com/topic/30643-take-out-emails-and-web-addresses-from-form-information/#findComment-141629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.