birdie Posted August 31, 2006 Share Posted August 31, 2006 hi, i need desperate help because i have never done anything like this in php.My aim is to get rid of html tags from a var.$var = "<div align=center>hell</div>";i found out that you could use regular expressions but dont know how to use them.I found <([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1> which should work (probably).How do i use it exactly in preg_replace or anything else?Thanks :) Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/ Share on other sites More sharing options...
redarrow Posted August 31, 2006 Share Posted August 31, 2006 when you say dir what do you mean as folder.name? Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83545 Share on other sites More sharing options...
birdie Posted August 31, 2006 Author Share Posted August 31, 2006 i'm sorry, i meant var (variable) Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83552 Share on other sites More sharing options...
Jenk Posted August 31, 2006 Share Posted August 31, 2006 [code]<?php$var = strip_tags('<div align="center">hell</div>');?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83556 Share on other sites More sharing options...
feri_soft Posted August 31, 2006 Share Posted August 31, 2006 or just $var = strip_tags($var); Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83559 Share on other sites More sharing options...
birdie Posted August 31, 2006 Author Share Posted August 31, 2006 oh i'm sorry if you miss understood this. I meant any html tags. Div was just an example$var could be..<table><div><br>etc etc. Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83571 Share on other sites More sharing options...
wildteen88 Posted August 31, 2006 Share Posted August 31, 2006 Strip tags will strip [b]all[/b] html tags from a string you pass to the strip_tags function.Read up on [url=http://php.net/strip-tags]strip_tags[/url] over at php.net. You dont need a regular expression. Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83572 Share on other sites More sharing options...
birdie Posted August 31, 2006 Author Share Posted August 31, 2006 oh wow thanks. I should have looked into that more. Sorry. Quote Link to comment https://forums.phpfreaks.com/topic/19268-php-regular-expressions/#findComment-83579 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.