Skip to content

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 y…

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 ‘ bec…

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 …

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…

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 d…