double-quotes

php to extract a string from double quote

夙愿已清 提交于 2019-11-26 22:45:36
问题 I have a string: This is a text, "Your Balance left $0.10", End 0 How can I extract the string in between the double quotes and have only the text (without the double quotes): Your Balance left $0.10 I have tried preg_match_all() but with no luck. 回答1: As long as the format stays the same you can do this using a regular expression. "([^"]+)" will match the pattern Double-quote At least one non-double-quote Double-quote The brackets around the [^"]+ means that that portion will be returned as

Is there any practical reason to use quoted strings for JSON keys?

三世轮回 提交于 2019-11-26 22:00:05
According to Crockford's json.org , a JSON object is made up of members , which is made up of pairs . Every pair is made of a string and a value , with a string being defined as: A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string. But in practice most programmers don't even know that a JSON key should be surrounded by double quotes, because most browsers don't require the use of double quotes. Does it make any sense to bother

Oracle SQL Syntax: Quoted identifier

☆樱花仙子☆ 提交于 2019-11-26 21:55:11
问题 I encountered SQL queries that looked like select "hello" from "foo"."bar" I found that we can have quoted and unquoted identifiers in Oracle: Database Object Names and Qualifiers ... A quoted identifier begins and ends with double quotation marks ("). If you name a schema object using a quoted identifier, then you must use the double quotation marks whenever you refer to that object... I asked the DBAs and they told me that there is a table with name bar but not "bar" Why is that? 回答1: The

Split string on commas but ignore commas within double-quotes?

笑着哭i 提交于 2019-11-26 20:49:02
I have some input that looks like the following: A,B,C,"D12121",E,F,G,H,"I9,I8",J,K The comma-separated values can be in any order. I'd like to split the string on commas; however, in the case where something is inside double quotation marks, I need it to both ignore commas and strip out the quotation marks (if possible). So basically, the output would be this list of strings: ['A', 'B', 'C', 'D12121', 'E', 'F', 'G', 'H', 'I9,I8', 'J', 'K'] I've had a look at some other answers, and I'm thinking a regular expression would be best, but I'm terrible at coming up with them. Lasse is right; it's a

bash alias command with both single and double quotes

限于喜欢 提交于 2019-11-26 15:42:10
问题 I have this command that does what I want but I can't get to alias it in my .bashrc (note that it uses both single and double quotes): svn status | awk '$1 =="M"{print $2;}' I've tried: alias xx="svn status | awk '$1 ==\"M\"{print $2;}'" And some other common sense combinations with no luck.. I know that bash is very picky with quotes.. So what's the correct way to alias it and why ? Thanks 回答1: You just need to escape it correctly. alias xxx="svn status | awk '\$1 ==\"M\"{print \$2;}'" 回答2:

Escaping separator within double quotes, in awk

时光毁灭记忆、已成空白 提交于 2019-11-26 13:44:48
I am using awk to parse my data with "," as separator as the input is a csv file. However, there are "," within the data which is escaped by double quotes ("..."). Example filed1,filed2,field3,"field4,FOO,BAR",field5 How can i ignore the comma "," within the the double quote so that I can parse the output correctly using awk? I know we can do this in excel, but how do we do it in awk? Dimitre Radoulov It's easy, with GNU awk 4 : zsh-4.3.12[t]% awk '{ for (i = 0; ++i <= NF;) printf "field %d => %s\n", i, $i }' FPAT='([^,]+)|("[^"]+")' infile field 1 => filed1 field 2 => filed2 field 3 => field3

PHP JSON String, escape Double Quotes for JS output

笑着哭i 提交于 2019-11-26 12:27:57
问题 I\'m creating a JSON string from a PHP array. I\'ve encoded it using json_encode() . $data = array( \'title\' => \'Example string\\\'s with \"special\" characters\' ); $data = json_encode( $data ); $data is localized using wp_localize_script() and is accessible via a global data variable. In the JS file I can access the information by the following: var data = data.replace( /"/g, \'\"\' ), jsonData = jQuery.parseJSON( data ); console.log( jsonData ); This results in an output of: { \"title\":

Remove double quote in json_encode()

北城以北 提交于 2019-11-26 11:31:34
问题 I want remove double quote in my json_encode, that is my code: <?php require_once \'config.inc.php\'; //## Clase Base de Datos require_once \'Database.class.php\'; //## Obtengo los parametros pasados por el metodo GET $params = $_REQUEST; $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $db->connect(); $result = mysql_query(\"SELECT * from ranking WHERE posicion BETWEEN \".$params[\'pos_ini\'].\" AND \".$params[\'pos_fi\']) or die(\'Could not query\'); if(mysql_num_rows($result))

Omitting the double quote to do query on PostgreSQL

时光总嘲笑我的痴心妄想 提交于 2019-11-26 09:49:57
问题 Simple question, is there any way to omit the double quote in PostgreSQL? Here is an example, giving select * from A; , I will retrieve ERROR: relation \"a\" does not exist , and I would have to give select * from \"A\"; to get the real result. Is there any way not to do the second and instead do the first on PostgreSQL? 回答1: Your problem with this query started when you created your table. When you create your table, don't use quotes. Use this: CREATE TABLE a ( ... ); Not this: CREATE TABLE

Convert all types of smart quotes with PHP

為{幸葍}努か 提交于 2019-11-26 09:34:49
问题 I am trying to convert all types of smart quotes to regular quotes when working with text. However, the following function I\'ve compiled still seems to be lacking support and proper design. Does anyone know how to properly get all quote characters converted? function convert_smart_quotes($string) { $quotes = array( \"\\xC2\\xAB\" => \'\"\', // « (U+00AB) in UTF-8 \"\\xC2\\xBB\" => \'\"\', // » (U+00BB) in UTF-8 \"\\xE2\\x80\\x98\" => \"\'\", // ‘ (U+2018) in UTF-8 \"\\xE2\\x80\\x99\" => \"\'