colap Posted January 28, 2012 Share Posted January 28, 2012 <pre> <pre class="brush:cpp"> <pre class="brush:javascript"> Those can be cpp,javascript,python ... etc. I need to change/replace these into: <pre> <pre class="brush:cpp"> <pre class="brush:javascript"> Those can be cpp,javascript,python ... etc. I need a generic regular expression for this? Can anyone provide the generic regular expression for this to replace? Trying=> $abc = str_replace(array($generic-regular-expression),'<pre> or <pre class="brush:cpp"> or <pre class="brush:javascript"> ..... ',$str); Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/ Share on other sites More sharing options...
Pikachu2000 Posted January 28, 2012 Share Posted January 28, 2012 You don't mean you want to do the same thing html_entity_decode already does, do you? Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312060 Share on other sites More sharing options...
colap Posted January 28, 2012 Author Share Posted January 28, 2012 This is not yet solved. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312077 Share on other sites More sharing options...
colap Posted January 29, 2012 Author Share Posted January 29, 2012 You don't mean you want to do the same thing html_entity_decode already does, do you? Hello, I need to do html_entity_decode for only one html code, not all html element. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312078 Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2012 Share Posted January 29, 2012 Then you're going to need to provide more information. Show a sample of the data before and after, and explain what should be changed, and what should be left as is, and why. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312086 Share on other sites More sharing options...
colap Posted January 29, 2012 Author Share Posted January 29, 2012 Then you're going to need to provide more information. Show a sample of the data before and after, and explain what should be changed, and what should be left as is, and why. Look at my original question. There i have told that it will be changed into <pre class="brush:cpp">. Though html_entity_decode does this job, but i don't want to do html_entity_decode for <br/> and other html elements. Other html elements will be as those were. Only you have to convert it to <pre class="brush:cpp">. But if i do html_entity_decode($alltexts); it converts all html element, that's not what i want. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312198 Share on other sites More sharing options...
Pikachu2000 Posted January 29, 2012 Share Posted January 29, 2012 I have looked at your original question yet again, and every html entity in it was indeed converted. There were no <br> tags or any other tags that were not converted, nor did you state anything like, "these are the only tags I want converted; the others should be left as-is", that's why I asked for more information. Your question was rather ambiguous. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312208 Share on other sites More sharing options...
AyKay47 Posted January 29, 2012 Share Posted January 29, 2012 to back pika up, since iv'e read this thread several times now. According to the contents of your original post, html_entity_decode is the perfect, simplest solution for this. So unless you took the code from the op out of context (which doesn't make sense if you want a correct answer the first time), you have your answer. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312210 Share on other sites More sharing options...
colap Posted January 29, 2012 Author Share Posted January 29, 2012 I have looked at your original question yet again, and every html entity in it was indeed converted. There were no <br> tags or any other tags that were not converted, nor did you state anything like, "these are the only tags I want converted; the others should be left as-is", that's why I asked for more information. The texts will not only contain <pre class="brush:cpp"> but also contain like <br> and other escaped form of html element, i need to convert only the pre tag not other html escaped tag. Quote Link to comment https://forums.phpfreaks.com/topic/255951-php-regular-expression-help/#findComment-1312227 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.