Jump to content

how i can replace whith range..?


marhoons

Recommended Posts

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

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

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!

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.