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? Quote 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? Quote 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); Quote 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); Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/224147-match-non-html-pattern/#findComment-1162878 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.