quotes

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

若如初见. 提交于 2019-11-29 03:01:14
For example: "I don't like these "double" quotes" and I want the output to be I don't like these double quotes cletus 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".replace("\"", "")); You don't need regex for this. Just a character-by-character replace is sufficient.

Can Python remove double quotes from a string, when reading in text file?

ぐ巨炮叔叔 提交于 2019-11-29 02:31:47
问题 I have some text file like this, with several 5000 lines: 5.6 4.5 6.8 "6.5" (new line) 5.4 8.3 1.2 "9.3" (new line) so the last term is a number between double quotes. What I want to do is, using Python (if possible), to assign the four columns to double variables. But the main problem is the last term, I found no way of removing the double quotes to the number, is it possible in linux? This is what I tried: #!/usr/bin/python import os,sys,re,string,array name=sys.argv[1] infile = open(name,

Java Regex for matching quoted string with escaped quotes

眉间皱痕 提交于 2019-11-29 02:24:16
I know there are already many questions like mine but I found no answer which works in Java. So I write a new question. I have text files with content like this: key1 = "This is a \"test\" text with escapes using '\\' characters"; key2 = 'It must work with \'single\' quotes and "double" quotes'; I need a regular expression which matches the values in the double-quotes (or single-quotes). This regular expression must support the escaped quotes and escaped backslashes. The regular expression must work with Java standard Pattern/Matcher classes. Try this regular expression: '([^\\']+|\\([btnfr"'\

What is the difference between square brackets and single quotes for aliasing in SQL Server?

六月ゝ 毕业季﹏ 提交于 2019-11-29 01:50:13
问题 I have seen some people alias column names using single quotes eg: select orderID 'Order No' from orders and others use square brackets eg: select orderID [Order No] from orders I tend to use square brackets. Is there any preference/difference? 回答1: To answer the question "is there any preference/difference": Yes, there are as many preferences as there are opinions, but be careful whose preferences you adopt. As a best practice, it is advisable to write portable SQL if it doesn't require any

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

我的梦境 提交于 2019-11-28 23:45:15
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? 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 of something unbalanced problems is to quit the sas session, and balance whatever is unbalanced before re

Java regex content between single quotes

六月ゝ 毕业季﹏ 提交于 2019-11-28 23:33:29
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 users' are disappointed Expected output: NONE Test Case: Tumblr's 'acquisition' complete but users'

Converting MS word “curly” quotes and apostrophes

妖精的绣舞 提交于 2019-11-28 23:27:08
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' Going off Thomas's answer, the code is: return text.replaceAll("[\\u2018\\u2019]", "'") .replaceAll("[\\u201C\\u201D]", "\""); Thomas Here's a very useful link for everyone dealing with Unicode: Unicode codepoint lookup/search tool . Searching for "quotation mark" gives ‘ (U+2018) LEFT SINGLE QUOTATION MARK ’

Converting ″Straight Quotes″ to “Curly Quotes”

大憨熊 提交于 2019-11-28 18:47:29
I have an application which uses a Javascript-based rules engine. I need a way to convert regular straight quotes into curly (or smart) quotes. It’d be easy to just do a string.replace for ["] , only this will only insert one case of the curly quote. The best way I could think of was to replace the first occurrence of a quote with a left curly quote and every other one following with a left, and the rest right curly. Is there a way to accomplish this using Javascript? You could replace all that preceed a word character with the left quote, and all that follow a word character with a right

Python “string_escape” vs “unicode_escape”

妖精的绣舞 提交于 2019-11-28 16:53:04
According to the docs , the builtin string encoding string_escape : Produce[s] a string that is suitable as string literal in Python source code ...while the unicode_escape : Produce[s] a string that is suitable as Unicode literal in Python source code So, they should have roughly the same behaviour. BUT, they appear to treat single quotes differently: >>> print """before '" \0 after""".encode('string-escape') before \'" \x00 after >>> print """before '" \0 after""".encode('unicode-escape') before '" \x00 after The string_escape escapes the single quote while the Unicode one does not. Is it

How to remove extra indentation of Python triple quoted multi-line strings?

给你一囗甜甜゛ 提交于 2019-11-28 16:36:29
问题 I have a python editor where the user is entering a script or code, which is then put into a main method behind the scenes, while also having every line indented. The problem is that if a user has a multi line string, the indentation made to the whole script affects the string, by inserting a tab in every space. A problem script would be something so simple as: """foo bar foo2""" So when in the main method it would look like: def main(): """foo bar foo2""" and the string would now have an