escaping

Escape dynamic strings in JavaScript

强颜欢笑 提交于 2019-12-20 03:38:27
问题 I'm writing a script for a signature function in a forum program and any time someone puts a quote or some other JavaScript parse-able character into it, it breaks my program. Is there a way either to force JavaScript to recognize it as a string without parsing it as script or, failing that, a function that escapes all scripting within a string that will be dynamic? I did a search and all I could find were endless webpages on how to escape individual characters with a slash - perhaps my

How to use backslash escape char for new line in JavaCC?

非 Y 不嫁゛ 提交于 2019-12-20 03:25:10
问题 I have an assignment to create a lexical analyser and I've got everything working except for one bit. I need to create a string that will accept a new line, and the string is delimited by double quotes. The string accepts any number, letter, some specified punctuation, backslashes and double quotes within the delimiters. I can't seem to figure out how to escape a new line character. Is there a certain way of escaping characters like new line and tab? Here's some of my code that might help <

Escaping an ampersand in SQL Server Full-Text Search query using CONTAINSTABLE

落爺英雄遲暮 提交于 2019-12-20 02:35:15
问题 I have a very peculiar case. My ASP.NET page calls a stored procedure of ours that performs a Full-Text Search query on our database. Some of the commonly searched strings include an ampersand because a few brands of our products (well-known brands, too) have an & in their name. It turns out that in a certain case I get no results unless I escape the ampersand ( \& ), and in a certain other case I get no results only if I escape the ampersand . I don't know if this is relevant, but (without

Escaping an ampersand in SQL Server Full-Text Search query using CONTAINSTABLE

眉间皱痕 提交于 2019-12-20 02:35:08
问题 I have a very peculiar case. My ASP.NET page calls a stored procedure of ours that performs a Full-Text Search query on our database. Some of the commonly searched strings include an ampersand because a few brands of our products (well-known brands, too) have an & in their name. It turns out that in a certain case I get no results unless I escape the ampersand ( \& ), and in a certain other case I get no results only if I escape the ampersand . I don't know if this is relevant, but (without

Escaping ] and ^ characters in a T-SQL “pattern” expression character class

梦想与她 提交于 2019-12-20 02:28:29
问题 I'm trying to emulate Oracle's RTRIM(expression, characters) in MsSql Server 2008 R2 with the following query: REVERSE( SUBSTRING( REVERSE(field), PATINDEX('%[^chars]%', REVERSE(field)), LEN(field) - PATINDEX('%[^chars]%', REVERSE(field)) + 1 ) ) The problem is that I want to be able to trim characters like ] and ^ which do probably need escaping. I don't know how to do this. Things like \] don't work. I'm aware of the ESCAPE clause but I do not understand exactly how it works and, by the way

Escape characters when generating Powershell scripts using C#

二次信任 提交于 2019-12-20 01:38:34
问题 I use VS2010, C#, .NET 3.5 for generate Powershell scripts (ps1 files). Then, it is required escape characters for Powershell. Any suggestions about it for develop good method that escape characters? public static partial class StringExtensions { /* PowerShell Special Escape Sequences Escape Sequence Special Character `n New line `r Carriage Return `t Tab `a Alert `b Backspace `" Double Quote `' Single Quote `` Back Quote `0 Null */ public static string FormatStringValueForPS(this string

LESS CSS Escape entire CSS rule with different prefixes?

坚强是说给别人听的谎言 提交于 2019-12-20 01:13:30
问题 How do i escape the following: .prefix(@rule, @prop) { -webkit-@{rule}: @{prop}; -moz-@{rule}: @{prop}; -o-@{rule}: @{prop}; -ms-@{rule}: @{prop}; @{rule}: @{prop}; } I've tried a bunch of different ways, wrapping it in ~"stuff" , wrapping the variables in @{var} , backslashing the - 's... no success! Edit: There's a pull req for it on Github: https://github.com/cloudhead/less.js/pull/698 回答1: Update for LESS 1.6+ Your original plan almost works with the LESS 1.6 update. This is the syntax

Python escape delimiter in configuration file using ConfigParser

梦想的初衷 提交于 2019-12-20 01:05:57
问题 I'd like to escape ":" and/or "=" as the name in a configuration file. Does anyone know how to achieve this? I try backslash "\", it does not work. 回答1: If you're using Python 3, you don't need to. Look at the Python docs section on Customizing Parser Behavior. By default, configparser uses ":" and "=" as delimiters, but you can specify different delimiters when you create the configparser object: import configparser parser = configparser.ConfigParser(delimiters=('?', '*')) In this example,

Echoing a tilde to a file without expanding it in Bash

僤鯓⒐⒋嵵緔 提交于 2019-12-19 17:41:44
问题 I need to write an argument to a file in a Bash script, so I'm doing something like this, echo "Argument is: $1" >> file The problem is that if there's a tilde (~) in the argument I don't want it expanded to the home directory. So if the user passed ~/bin as an argument to the script, it would get written as ~/bin and not /home/user/bin. How do I do this? 回答1: I assume your program is started as: $ your_prog ~/foo The argument is translated before your program is even started, so there's