marhoons Posted March 1, 2007 Share Posted March 1, 2007 Hello, I use Editor (WYSIWYG) To add an article.. any way the problem become if i use Microsoft Word with footnote he has attach the admin url! sach as: <a title="" style="mso-footnote-id: ftn4" href="http://localhost/eassy/control/article.php?cat=12#_ftn4" name=_ftnref4><span dir=ltr style="mso-special-character: footnote"> http://localhost/eassy/control/article.php?cat=12 I need to clean that url above.. I can use : $replac=str_replace("http://localhost/eassy/control/article.php","",$txt); But i have alot of section (?cat=12,?cat=105,......) it not possible way to write all url's section to clean it! what i can do for that any one have an idea..? or how i can remove an url until the #! Like.. href="http://localhost/eassy/control/article.php?cat=12#_ftn4" after clean become href="#_ftn4" Thanks alot, Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/ Share on other sites More sharing options...
effigy Posted March 1, 2007 Share Posted March 1, 2007 <pre> <?php $string = 'http://localhost/eassy/control/article.php?cat=12#_ftn4'; echo preg_replace('/^.+(?=#)/', '', $string); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197239 Share on other sites More sharing options...
craygo Posted March 1, 2007 Share Posted March 1, 2007 if you want everythign after the # sign you can use strrchr. <?php $http = 'http://localhost/eassy/control/article.php?cat=12#_ftn4'; $new = strrchr($http, "#"); echo $new; ?> This will find the LAST instance of # and echo everything after it Ray Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197243 Share on other sites More sharing options...
marhoons Posted March 1, 2007 Author Share Posted March 1, 2007 Thanks.. But we have big prob. how i can catch the url in code to clean it! sach as: <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"></P> <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"> <A name=4> <SPAN lang=AR-IQ>Test</SPAN></A><SUP><SPAN lang=AR-IQ>(<span class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><sup><span lang=AR-IQ> <a title="" style="mso-footnote-id: ftn4" href="http://localhost/eassy/control/article.php?cat=25#_ftn4" name=_ftnref4><span dir=ltr style="mso-special-character: footnote"><sup> <span style="FONT-SIZE: 13pt; FONT-FAMILY: 'Simplified Arabic'; mso-ascii-font-family: 'Simplified Arabic'; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: 'Simplified Arabic'; mso-bidi-language: AR-IQ; mso-ansi-language: EN-US; mso-fareast-language: EN-US">[4]</span></sup></span></a></span></sup></span>)</SPAN></SUP><SPAN lang=AR-IQ>: <o:p></o:p> </SPAN></P> <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"><SPAN lang=AR-IQ>"إِذا example..example..example.example..example..example..example..example..example..example <o:p></o:p> </SPAN></P> <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"><SPAN lang=AR-IQ> <o:p> </o:p> </SPAN></P> How i can catch url and replace with out affect in code! Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197275 Share on other sites More sharing options...
effigy Posted March 1, 2007 Share Posted March 1, 2007 echo preg_replace('/(?<=href=")([^"#]+)/', '', $all_of_your_code); Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197319 Share on other sites More sharing options...
marhoons Posted March 1, 2007 Author Share Posted March 1, 2007 it's not work my darling.. Nothing replace....! Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197339 Share on other sites More sharing options...
effigy Posted March 1, 2007 Share Posted March 1, 2007 This works for me: <pre> <?php $code = <<<CODE <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"></P> <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"> <A name=4> <SPAN lang=AR-IQ>Test</SPAN></A><SUP><SPAN lang=AR-IQ>(<span class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><sup><span lang=AR-IQ> <a title="" style="mso-footnote-id: ftn4" href="http://localhost/eassy/control/article.php?cat=25#_ftn4" name=_ftnref4><span dir=ltr style="mso-special-character: footnote"><sup> <span style="FONT-SIZE: 13pt; FONT-FAMILY: 'Simplified Arabic'; mso-ascii-font-family: 'Simplified Arabic'; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: 'Simplified Arabic'; mso-bidi-language: AR-IQ; mso-ansi-language: EN-US; mso-fareast-language: EN-US">[4]</span></sup></span></a></span></sup></span>)</SPAN></SUP><SPAN lang=AR-IQ>: <o:p></o:p> </SPAN></P> <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"><SPAN lang=AR-IQ>"???? example..example..example.example..example..example..example..example..example..example <o:p></o:p> </SPAN></P> <P class=MsoNormal dir=rtl style="MARGIN: 0cm 0cm 0pt"><SPAN lang=AR-IQ> <o:p> </o:p> </SPAN></P> CODE; echo preg_replace('/(?<=href=")([^"#]+)/', '', $code); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197346 Share on other sites More sharing options...
marhoons Posted March 1, 2007 Author Share Posted March 1, 2007 Oh!!! Thanks its ok.. Link to comment https://forums.phpfreaks.com/topic/40741-how-i-can-replace-whith-range/#findComment-197348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.