delimiter

What delimiters can you use in sed?

这一生的挚爱 提交于 2019-11-27 05:17:20
We normally see people complaining about the unknown option to s' error in sed when they want to use a pattern that contains the sed delimiter. For example, if we are using / : $ var="hel/lo" $ sed "s/a/$var/g" <<< "haha" sed: -e expression #1, char 9: unknown option to `s' So we advise to use another delimiter, for example | : $ sed "s|a|$var|g" <<< "haha" hhel/lohhel/lo However, I want to know what are the possible delimiters sed can accept... since it seems to be almost any character including regex-like ones ( * , ? , . , ...)! In my sed (GNU sed) 4.2.2 : $ sed 's/a/b/g' <<< "haha" hbhb $

Split delimited string value into rows

99封情书 提交于 2019-11-27 03:40:05
问题 Some external data vendor wants to give me a data field - pipe delimited string value, which I find quite difficult to deal with. Without help from an application programming language, is there a way to transform the string value into rows? There is a difficulty however, the field has unknown number of delimited elements. DB engine in question is MySQL. For example: Input: Tuple(1, "a|b|c") Output: Tuple(1, "a") Tuple(1, "b") Tuple(1, "c") 回答1: It may not be as difficult as I initially

Convert column with pipe delimited data into dummy variables [duplicate]

拥有回忆 提交于 2019-11-27 03:31:24
问题 This question already has an answer here: Split a column into multiple binary dummy columns [duplicate] 1 answer I'm interested in taking a column of a data.frame where the values in the column are pipe delimited and creating dummy variables from the pipe-delimited values. For example: Let's say we start with df = data.frame(a = c("Ben|Chris|Jim", "Ben|Greg|Jim|", "Jim|Steve|Ben")) > df a 1 Ben|Chris|Jim 2 Ben|Greg|Jim 3 Jim|Steve|Ben I'm interested in ending up with: df2 = data.frame(Ben = c

Hive query output delimiter

拜拜、爱过 提交于 2019-11-27 02:59:36
问题 I have 2 tables in Hive - first is external, the second one is managed. Managed table is populated from external using INSERT OVERWRITE...SELECT FROM external_table. Both tables are created with row delimited by ','. When I run selects queries into file, the delimiter in result file is Tab, but I need comma. How to change it to comma, I see no properties for that. 回答1: First of all, you need to change you field delimiter , not your line delimiter ie. hive >> CREATE TABLE some_table (col1 int,

Java - Using multiple delimiters in a scanner

爱⌒轻易说出口 提交于 2019-11-27 02:44:39
问题 I'm using a scanner to take input and, hopefully, split it into chunks. I want it to split it up using whole word delimiters. So right now I have: Scanner scanner = new Scanner("1 imported bottle of perfume at 27.99"); scanner.useDelimiter("\\sdelimitOne\\s"); So with input "word word delimitOne word word delimitTwo word word" I get output: word word word word delimitTwo word word I was hoping scanner.useDelimiter("\\sdelimitOne\\s\\sdelimitTwo\\s"); might work, but alas not. How do I go

Eclipse and Windows newlines

元气小坏坏 提交于 2019-11-27 02:34:39
I had to move my Eclipse workspace from Linux to Windows when my desktop crashed. A week later I copy it back to Linux, code happily, commit to CVS. And alas, windows newlines have polluted many files, so CVS diff dumps the entire file, even when I changed a line or two! I could cook up a script, but I am wondering if it will mess up my Eclipse project files. As mentioned here and here : Set file encoding to UTF-8 and line-endings for new files to Unix, so that text files are saved in a format that is not specific to the Windows OS and most easily shared across heterogeneous developer desktops

How do I extract lines between two line delimiters in Perl?

随声附和 提交于 2019-11-27 01:57:08
问题 I have an ASCII log file with some content I would like to extract. I've never taken time to learn Perl properly, but I figure this is a good tool for this task. The file is structured like this: ... ... some garbage ... ... garbage START what i want is on different lines END ... ... more garbage ... next one START more stuff I want, again spread through multiple lines END ... more garbage So, I'm looking for a way to extract the lines between each START and END delimiter strings. How can I

String delimiter in string.split method

爷,独闯天下 提交于 2019-11-27 01:01:47
问题 I have following data: 1||1||Abdul-Jabbar||Karim||1996||1974 I want to delimit the tokens. Here the delimiter is "||" . My delimiter setter is: public void setDelimiter(String delimiter) { char[] c = delimiter.toCharArray(); this.delimiter = "\"" + "\\" + c[0] + "\\" + c[1] + "\""; System.out.println("Delimiter string is: " + this.delimiter); } However, String[] tokens = line.split(delimiter); is not giving the required result. 回答1: There is no need to set the delimiter by breaking it up in

MySQL DELIMITER syntax errors

六月ゝ 毕业季﹏ 提交于 2019-11-26 23:19:56
问题 This MySQL script installs multiple triggers. It works on one machine running MySQL 5.0.51b-community. On another machine running MySQL 14.12 Distrib 5.0.45, for redhat-linux-gnu (i386) it fails, with this error message, which seems to be related to the DELIMITER // ... // DELIMITER ; syntax : ERROR 1064 (42000) at line 272: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER; DROP TRIGGER IF EXISTS

Angular JS custom delimiter

自古美人都是妖i 提交于 2019-11-26 21:38:43
How do I use a custom delimiter for angular JS? I'd like to change from the {{ var }} syntax to [[ var ]] . Can somebody show me a complete example on how to implement this with Angular? You can use $interpolateProvider to change start / end symbols used for AngularJS expressions: var myApp = angular.module('myApp', [], function($interpolateProvider) { $interpolateProvider.startSymbol('[['); $interpolateProvider.endSymbol(']]'); }); and then, in your template: Hello, [[name]] Here is the working jsFiddle: http://jsfiddle.net/Bvc62/3/ Check the documentation on the $interpolate service here: