quotes

How do you replace double quotes with a blank space in Java?

旧街凉风 提交于 2019-11-27 17:17:18
问题 For example: "I don't like these "double" quotes" and I want the output to be I don't like these double quotes 回答1: Use String#replace(). To replace them with spaces (as per your question title): System.out.println("I don't like these \"double\" quotes".replace("\"", " ")); The above can also be done with characters: System.out.println("I don't like these \"double\" quotes".replace('"', ' ')); To remove them (as per your example): System.out.println("I don't like these \"double\" quotes"

Escape JavaScript quotes in EL in a JSF component attribute

◇◆丶佛笑我妖孽 提交于 2019-11-27 16:27:20
I have an onclick event that depends on the state of a variable. So I need to do something like onclick="#{object.isEnabled ? 'ch.my.js_method('#{object.property}'); return false;' : 'return false;'" The problem is, that I can't use ' inside of the onclick. How can I escape the quotes inside of the EL? BalusC You can escape them with \ or \\ , but rules differ per EL implementation, because it isn't clear cut in EL spec (Oracle's EL impl needs single backslash, but Apache needs double backslash). And you need the += operator to string-concatenate the EL expression. <x:someComponent onclick="#

Are there different types of double quotes in utf-8 (PHP, str_replace)?

倖福魔咒の 提交于 2019-11-27 15:33:05
In PHP 5.3, am trying to replace double quotes in a string as such: $bar = str_replace('"','\'',$foo); But some quotes that are saved in the utf8-Database are not being replaced, although they look perfectly normal: "Some text" Are there different character types I have to search for? If so, which are they? There are many characters that look like quotation marks, most of them are used infrequently. The ones that are used more often are these three: " U+0022 QUOTATION MARK “ U+201C LEFT DOUBLE QUOTATION MARK ” U+201D RIGHT DOUBLE QUOTATION MARK Some rarer ones are FULLWIDTH QUOTATION MARK, the

Java regex content between single quotes

ⅰ亾dé卋堺 提交于 2019-11-27 15:05:57
问题 I am trying to write a regex in Java to find the content between single quotes. Can one please help me with this? I tried the following but it doesn't work in some cases: Pattern p = Pattern.compile("'([^']*)'"); Test Case: 'Tumblr' is an amazing app Expected output: Tumblr Test Case: Tumblr is an amazing 'app' Expected output: app Test Case: Tumblr is an 'amazing' app Expected output: amazing Test Case: Tumblr is 'awesome' and 'amazing' Expected output: awesome, amazing Test Case: Tumblr's

What's your best trick to break out of an unbalanced quote condition in BASE SAS?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 15:00:11
问题 As a base SAS programmer, you know the drill: You submit your SAS code, which contains an unbalanced quote, so now you've got not only and unclosed quote, but also unclosed comments, macro function definitions, and a missing run; or quit; statement. What's your best trick for not having those unbalanced quotes bother you? 回答1: enterprise guide 3 used to put the following line at the top of its automatically generated code: *';*";*/;run; however, the only way to really "reset" from all kinds

Converting MS word “curly” quotes and apostrophes

懵懂的女人 提交于 2019-11-27 14:59:15
问题 How do I convert the MS Word quotes and apostrophes to regular quotes and apostrophes characters in Java? What's the unicode number for these characters? “how are you doing?” ‘howdy’ Since Stack Overflow autofixes them, here's how they appear in an editor to "how are you doing?" 'howdy' 回答1: Going off Thomas's answer, the code is: return text.replaceAll("[\\u2018\\u2019]", "'") .replaceAll("[\\u201C\\u201D]", "\""); 回答2: Here's a very useful link for everyone dealing with Unicode: Unicode

Are quotes around hash keys a good practice in Perl?

只愿长相守 提交于 2019-11-27 13:53:29
Is it a good idea to quote keys when using a hash in Perl? I am working on an extremely large legacy Perl code base and trying to adopt a lot of the best practices suggested by Damian Conway in Perl Best Practices . I know that best practices are always a touchy subject with programmers, but hopefully I can get some good answers on this one without starting a flame war. I also know that this is probably something that a lot of people wouldn't argue over due to it being a minor issue, but I'm trying to get a solid list of guidelines to follow as I work my way through this code base. In the Perl

How to insert text with single quotation sql server 2005

╄→гoц情女王★ 提交于 2019-11-27 13:26:53
I want to insert text with single quote Eg john's to table in sql server 2005 database Escape single quote with an additional single as Kirtan pointed out And if you are trying to execute a dynamic sql (which is not a good idea in the first place) via sp_executesql then the below code would work for you sp_executesql N'INSERT INTO SomeTable (SomeColumn) VALUES (''John''''s'')' The answer really depends on how you are doing the INSERT . If you are specifying a SQL literal then you need to use the double-tick approach: -- Direct insert INSERT INTO Table1 (Column1) VALUES ('John''s') -- Using a

Write CSV To File Without Enclosures In PHP

血红的双手。 提交于 2019-11-27 12:17:27
Is there a native function or solid class/library for writing an array as a line in a CSV file without enclosures? fputcsv will default to " if nothing is passed in for the enclosure param. Google is failing me (returning results for a whole bunch of pages about fputcsv ), and PEAR's libraries do more or less the same things as fputcsv . Something that works exactly like fputcsv , but will allow the fields to remain unquoted. currently: "field 1","field 2",field3hasNoSpaces desired: field 1,field 2,field3hasNoSpaces The warnings about foregoing enclosures are valid, but you've said they don't

What is the use case for Ruby's %q / %Q quoting methods?

梦想的初衷 提交于 2019-11-27 10:50:32
I've been reading through Thomas' Programming Ruby 1.9 and came upon the alternative delimited single and double-quoting methods ( %q / %Q ). I've known of them from other Ruby language references as well. %q/I'm acting like a single-quoted string/ %Q|"I'm acting like a double-quoted string" --Anonymous| I have not been working with Ruby for long, but I have never encountered this quoting method in production code. Other than the obvious ability to avoid internally escaping quotes with backslashes, what are the common use cases for this method of quoting over regular single or double quotes?