[Project_owners] &amp and &regl in links/uri's

Michael Vincent mv_van_rantwijk at yahoo.com
Tue Sep 6 19:51:54 EDT 2005


Claus Augusti wrote:
> Hi Michael,
> 
> your question isn't really clear... what exactly are you trying to do?

I read some remote XML files and some of them are invalid XML (because 
they use & instead of & for example) but that should not break my 
code ;)

> You can use the & inside HTML links, as it's replaced by & during 
> parsing, so you can use both to separate key/value pairs inside the 
> query string. In XHTML/XML you have to use the entity version anyways.
> 
> If you want to send an ampersand as part of a key's value and not to 
> separate key/value pairs, you need to do URI encoding, which is done by
> 
> escape("Barnes&Noble")
> or
> escapeURIComponent("Barnes&Noble"), which is the Unicode-safe version.

Can that be used in a web based application (I don't have access to a 
chrome window, as far as I know).

> However, the regex to replace & by & is:
> 
> text = "foo=bar&bar=baz";
> text = text.replace( /&/g, "&" );

Yes, but that breaks for uri's like this:

../somepage.html?id=foo&number=somenumber

That is what I like to solve...if possible

Thanks,
Michael


More information about the Project_owners mailing list