quotation-marks

Removing whitespace-characters, except inside quotation marks in PHP?

心不动则不痛 提交于 2019-12-04 11:46:15
I need to remove all whitespace from string, but quotations should stay as they were. Here's an example: string to parse: hola hola "pepsi cola" yay output: holahola"pepsi cola"yay Any idea? I'm sure this can be done with regex, but any solution is okay. We could match strings or quotations with [^\s"]+|"[^"]*" So we just need to preg_match_all and concatenate the result. Example : $str = 'hola hola "pepsi cola" yay'; preg_match_all('/[^\s"]+|"[^"]*"/', $str, $matches); echo implode('', $matches[0]); // holahola"pepsi cola"yay zx81 Martti, resurrecting this question because it had a simple

Replacing quotation marks in Javascript?

谁说胖子不能爱 提交于 2019-12-04 03:50:52
For a web app I'm making, I'm going to be getting text strings coming in, occasionally which contain quotation marks. Because I am then going to be document.writing the string, they need to be changed either into apostrophes or escaped. How would I do that, because when I try it doesn't seem to work, specifically I think because the string's quotation marks stop the rest of the script working. Hope that makes some sense, I'm quite new to this so that's why it might not make sense. I'll try and clarify if need be. Thank you! Escaping them for HTML: var escapedString = string.replace(/'/g, "

What Quotation Marks Should I Use In CSS? [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-03 14:27:38
This question already has answers here : Which type of quotes we should use in css background url (“…”)? Single, double or no quote needed? [duplicate] (5 answers) Possible Duplicate: Which type of quotes we should use in css background url (“…”)? Single, double or no quote needed? Simple question. What quotation marks should I use in CSS? Option #1: background: url( 'foo.png' ); Option #2: background: url( "foo.png" ); Both works on "normal browsers". I just want to follow the standards. The standards say : The format of a URI value is 'url(' followed by optional white space followed by an

Need third kind of quotation marks in JavaScript

和自甴很熟 提交于 2019-12-02 22:09:45
问题 I'm changing the HTML using javascript. Therefore, I have a String that saves the HTML code, since it is produced in a for-loop. In it there is an <a> tag. To the <a> tag I want to add an onClick which calls a function with a parameter which is saved in a javascript variable. let parameter = "p1"; let to_html_String = "<a href='#' onClick='create_sprite_window("+parameter+")'></a>"; document.getElementById('sidebar_left_sprites').innerHTML = to_html_String; This does not work because it would

Unmatched quotation mark issue in SAS

柔情痞子 提交于 2019-12-01 22:19:00
问题 As is known to all, SAS needs special care to quotation marks inside a sentence. E.g. %let quoted="I'd like to"; data temp; set temp; quoted="&quoted"; run; error is encounterred when submitting. In fact I need to copy data to one dataset from another one, in which there are a lot of records containing quotation marks. When assigning, error occurrs and data step stop executing, causing rest of the code to be invalid. So in this case, it's impossible to modify original data set by adding

Unmatched quotation mark issue in SAS

喜你入骨 提交于 2019-12-01 21:14:42
As is known to all, SAS needs special care to quotation marks inside a sentence. E.g. %let quoted="I'd like to"; data temp; set temp; quoted="&quoted"; run; error is encounterred when submitting. In fact I need to copy data to one dataset from another one, in which there are a lot of records containing quotation marks. When assigning, error occurrs and data step stop executing, causing rest of the code to be invalid. So in this case, it's impossible to modify original data set by adding duplicated quotation marks, which doesn't make sense. So instead of having to add a duplicated one, like, "I

Quotation mark in string

眉间皱痕 提交于 2019-11-29 14:28:52
I have some string with variable, e.g. string path = @"C:\one\filename.exe" + arguments arguments: "-s -c -d > "somedirectory\some file.txt"" I've problem with redirection output to "somedirectory\some file" If I put "\"" or char.ToString('"') it always interprets as \" ...not alone " How should I put this " character into arguments? You need to use \" . The debugger shows it as \" , since it shows valid string literals. However, the actual value in the string is " . (You can see this in the Text Visualizer) In a verbatim string literal ( @"..." ), you need to use "" instead. var arguments = @

Using left double quotation marks in strings in VB

这一生的挚爱 提交于 2019-11-29 13:09:46
In following code, the usage of the string "“" (i.e. a left double quotation mark inside a string) results in a compile error in VB.NET: StringVar = Replace(StringVar, "“", "“") What’s going on here? It seems as if you want to replace curly quotes with their HTML code equivalent. On the first glance, your code is absolutely correct. The problem is that VB allows curly quotes in place of regular quotes in code (because Unicode is great, right?). That is, the following codes are all equivalent: Dim str = "hello" Dim str = “hello” Dim str = "hello“ Now, if you want to use a quotation mark inside

Using left double quotation marks in strings in VB

ⅰ亾dé卋堺 提交于 2019-11-28 07:02:30
问题 In following code, the usage of the string "“" (i.e. a left double quotation mark inside a string) results in a compile error in VB.NET: StringVar = Replace(StringVar, "“", "“") What’s going on here? 回答1: It seems as if you want to replace curly quotes with their HTML code equivalent. On the first glance, your code is absolutely correct. The problem is that VB allows curly quotes in place of regular quotes in code (because Unicode is great, right?). That is, the following codes are all

How to print variable inside quotation marks? [closed]

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 00:11:04
I would like to print a variable within quotation marks. I want to print out "variable" I have tried a lot, what worked was: '"', variable", '"' – but then I have two spaces in the output -> " variable " When I do print '"'variable'"' without the comma I get a syntax error. How can I print something within a pair of quotation marks? you can use format : >>> s='hello' >>> print '"{}"'.format(s) "hello" Learn about format here: Format Mike Housky If apostrophes ("single quotes") are okay, then the easiest way is to: print repr(str(variable)) Otherwise, prefer the .format method over the %