You are here: Re: Regular Expressions « PHP Programming Language « IT news, forums, messages
Re: Regular Expressions

Posted by Erwin Moller on 09/28/14 12:02

UKuser wrote:
> Hi Guys,
>
> I am currently working on the following to completely replace the <a
> href> tag and all content but its not working:
>
> $input = "<a href=\"some_random_text.html?tes=hello&str=pol%20\">Text
> here</a>";
> echo ereg_replace('<a href="[A-Za-z0-9._-][&\?=]+">',"", $input);

At first glance:
[A-Za-z0-9._-] is a characterclass, but you forgot the + after it, so it
matches 1 or more times.

Secondly: [&\?=]+ will not match
test.html?name=joe&age=11

Wouldn't it be easier to simply try to match:
1) begins with: <a href="
2) then anything
3) ends with: >

in a nongreedy way?

Regards,
Erwin Moller


>
> Will keep working on it but if you get there first any help would be
> great.
>
> Thanks
>
> A

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация