Skip to content
Advertisement

Tag: escaping

Regex expression not returning entire term

The intention of the regex is to capture substrings wrapped between twin expressions in parentheses, kinda like html tags. For example: And here’s my code Can anyone tell me why this doesn’t capture the entire thing? Answer The characters () are special in a regexp and must be escaped with a if you want to match them literally. And

Escaping ” or ‘ multiple times

So I often have to generate content for webpages through servlets or jsps. In that process I sometimes run into a problem when trying to escape multiple layers of ” or ‘ when working with strings. For example I’m creating an element with a popup here: I cannot use the alternative ‘ because the text is full of them, so

Why is “” invalid in JavaScript?

While writing “” in Chrome console I get the following error: In Firefox it gives following error: while writting “\” gives: “\” in both browsers What is the proper way to write “” in JavaScript? Answer Do not let the rendering of a string in the console, which may display strings including escape sequences and wrapped in quotes because it

Escaping quotes in Javascript variable from Classic ASP

How can I escape quotes using a Classic ASP variable in javascript/jQuery? The ASP variable is taken from a DB. I’m using: But obviously that appears as when the page loads, which breaks the function with unexpected identifier. edit: I’m using using jQuery not “how can I achieve this using jQuery” sorry wasn’t clear. Any ideas? Thanks Answer You’ve asked

How to write a value that contains a comma to a csv file?

I have a javascript program to write values to a csv file. I have a value that includes comma within. How to do this? I am newbie to javascript. can you please help me? I tried double quotes record.assets is the field that will have comma within. Answer Close them in quotes and escape double quotes? http://en.wikipedia.org/wiki/Comma-separated_values 1999,Chevy,”Venture “”Extended Edition”””,4900.00

Single quotes in string with jQuery ajax

I have run into a problem where the user enters data and if there are single quotes at all, the script errors out. What’s the best way to handle single quotes that users enter so it doesn’t interfere with the jquery/javascript? UPDATE: I’m sending it through ajax to a database. here is the data parameter for a json ajax call.

Advertisement