Em Andamento

Regular Expression to operate on part of a string

I have a script that processes a string of user input. The user input can be HTML, XHTML, BBcode, whatever. It can have an unknown number of tags and an unknown number of attributes.

The whole script works perfectly except that it breaks dynamic urls (with the equals sign)... It breaks these "=" containing urls because it uses the equals sign to split tag attributes, and so it splitls the url. This is bad, as I need to preserve the urls.

The script is set up so that to iron out this bug, all I need to be able to do is TEMPORARILY eliminate the = signs INSIDE an href attribute.

Because the tag(s) can have an unlimited number of unknown attributes, I'm having trouble designing a procedure to do this. To complicate things, the script cannot predict the incoming url. To complicate things further, the script does not know whether the user input will contain single quotes, double quotes, or no quotes.

if I say 'href="http://google.com"' in a tag, the browser will parse it. If I say "href='[url removed, login to view]'" in a tag, the browser will parse it. And unfortunately, the browser will also parse "href=http://google.com"

So believe that the best way to do it is to create the mother of all regular expressions. The preferred form is:

$text = preg_replace($a, $b, $text)

The preferred result is...

FROM THIS:

<a href="[url removed, login to view]; title="foobar" target_"blank"><img ilo-full-src="[url removed, login to view]; src="../img/logo.gif" alt="GetAFreelancer.com" border="0" height="66" width="339"></a>

TO THIS:

<a href="[url removed, login to view]; title="foobar" target_"blank"><img ilo-full-src="[url removed, login to view]; src="../img/logo.gif" alt="GetAFreelancer.com" border="0" height="66" width="339"></a>

Hey, I didn't say it would be easy. If you're going to bid, please think carefully about what I'm after. Simply doing a

replace('=', '_EQUALS_SIGN_', $text) is not going to work, because that will convert the "=" in "href=", the equals in "target=" and the equals in "title=" and whatever other attributes a user might have dreamed up to sneak in there. And this is a very, very bad thing.

I really have no idea how much time writing this expression should take. As this is the first project I've ever generated, I'm not even sure if you can leave comments.

I'm not even sure if it's feasible.

Habilidades: PHP

Ver mais: php regex equals sign, writing height, writing gif, writing expressions, writing bug, writing procedure, uses regular expressions, up string, to string, thing logo, text string, string the, string i, string b, quotes writing, php string html, n equals, m string, create google logo html, create logo image text, regular expressions work, first form writing, easy way create logo, designing text logo, create logo bar

Acerca do Empregador:
( 1 comentário ) Christchurch, New Zealand

ID do Projeto: #174626

Premiar a:

kskulkarni

Hello, Please see PMB. Changed bid amount. The script is ready. Ketan Kulkarni

$60 USD em 0 dias
(3 Avaliações)
3.2