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

Claus Augusti caugusti at formatvorlage.de
Tue Sep 6 19:36:50 EDT 2005


Hi Michael,

your question isn't really clear... what exactly are you trying to do?

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.

However, the regex to replace & by & is:

text = "foo=bar&bar=baz";
text = text.replace( /&/g, "&" );

Regards,
Claus


Michael Vincent wrote:

> Hi,
>
> Is is allowed to have stuff like & and @reg; in links?
>
> Also, what regex do I need to replace & in & in links, and when 
> can that somehow fail? Are there special edge cases to watch out for?
>
> Has anyone ever done something like this before for one of their 
> projects?
>
> Aha, I smell food :-) food food food :-)
>
> Later,
> Michael
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners




More information about the Project_owners mailing list