ejaboneta Posted January 12, 2011 Share Posted January 12, 2011 I'm trying to build a language translation function that sends content to google's translation service. The problem I'm having is that the html code is sent with it and I don't want that. So I'm trying to figure out a way to use preg_replace() to match anything thats not html code. I figure if I match anything thats not between < and >, I could get what I'm looking for. I'm just not sure how to do that. How can I do this? Link to comment https://forums.phpfreaks.com/topic/224147-match-non-html-pattern/ Share on other sites More sharing options...
Pikachu2000 Posted January 12, 2011 Share Posted January 12, 2011 Like strip_tags, perhaps? Link to comment https://forums.phpfreaks.com/topic/224147-match-non-html-pattern/#findComment-1158247 Share on other sites More sharing options...
.josh Posted January 12, 2011 Share Posted January 12, 2011 def use strip_tags() but if for whatever reason you insist on using regex, you can use this: $content = preg_replace('~<[^>]*>~','',$content); Link to comment https://forums.phpfreaks.com/topic/224147-match-non-html-pattern/#findComment-1158372 Share on other sites More sharing options...
ejaboneta Posted January 17, 2011 Author Share Posted January 17, 2011 I'll try the regex. I still need the html code, I just dont want it to be sent to my function translate(). something like this: $content = preg_replace('~<[^>]*>~',translate($1),$content); Link to comment https://forums.phpfreaks.com/topic/224147-match-non-html-pattern/#findComment-1161024 Share on other sites More sharing options...
sasa Posted January 21, 2011 Share Posted January 21, 2011 look preg_replace_callback() function Link to comment https://forums.phpfreaks.com/topic/224147-match-non-html-pattern/#findComment-1162878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.