delimiter

bash read loop only reading first line of input variable

ぐ巨炮叔叔 提交于 2019-12-23 23:02:15
问题 I have a read loop that is reading a variable but not behaving the way I expect. I want to read every line of my variable and process each one. Here is my loop: while read -r line do echo $line | sed 's/<\/td>/<\/td>$/g' | cut -d'$' -f2,3,4 >> file.txt done <<< "$TABLE" I expect it to process every line of the file but instead it just does the first one. If my the middle is simply echo $line >> file.txt it works as expected. What's going on here? How do I get the behavior I want? 回答1: It

R strsplit before ( and after ) keeping both delimiters

喜夏-厌秋 提交于 2019-12-23 12:55:57
问题 I have a string that looks like the following: x <- "01(01)121210(01)0001" I want to split this into a vector so that i get the following: [1] "0" "1" "(01)" "1" "2" "1" "2" "1" "0" "(01)" "0" "0" "0" "1" The (|) could be [|] or {|} and the number of digits between the brackets can be 2 or more. I've been trying to do this by separating on the brackets first: unlist(strsplit(x, "(?<=[\\]\\)\\}])", perl=T)) [1] "01(01)" "121210(01)" "0001" or unlist(strsplit(x, "(?<=[\\[\\(\\{])", perl=T)) [1]

Cobol String Delimited By Trailing SPACES

穿精又带淫゛_ 提交于 2019-12-23 12:45:54
问题 WORKING-STORAGE. FIRST-STRING PIC X(15) VALUE SPACES. SECOND-STRING PIC X(15) VALUE SPACES. OUTPUT-STRING PIC X(31) VALUE SPACES. If FIRST-NAME = 'JON SNOW, ' and LAST-NAME = 'KNOWS NOTHING. ' , how can I get: I want to Get : OUTPUT-STRING = 'JON SNOW, KNOWS NOTHING. ' When I try : String FIRST-STRING DELIMITED BY SPACES ' ' DELIMITED BY SIZE SECOND-STRING DELIMITED BY SIZE INTO OUTPUT-STRING I Get 'JON KNOWS NOTHING. ' And When I try : String FIRST-STRING DELIMITED BY SIZE SECOND-STRING

Escaping quotes and delimiters in CSV files with Excel

廉价感情. 提交于 2019-12-23 09:21:27
问题 I try to import a CSV file in Excel, using ; as delimiters, but some columns contains ; and/or quotes. My problem is : I can use double quotes to ignore the delimiters for a specific string, but if there is a double quote inside the string, it ignores delimiters until the first double quote, but not after. I don't know if it's clear, it's not that easy to explain. I will try to explain with a example : Suppose I have this string this is a;test : I use double quotes around the string, to

Cannot cin.ignore till EOF?

丶灬走出姿态 提交于 2019-12-23 03:07:54
问题 I wanted to ignore all characters in cin to flush cin in this answer: How to get rid of bad input one word at a time instead of one line at a time? But I found that the program seemed to hang awaiting input if I wrote: cin.ignore(std::numeric_limits<std::streamsize>::max()); It propperly flushed cin if I used the '\n' delimiter: cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); My question is, why can't I just ignore till EOF? Why do I have to provide the delimiter? 回答1: The

Multiple delimiters in column headers also separates the row values

為{幸葍}努か 提交于 2019-12-22 18:03:35
问题 I had a some issue about defining multiple seperator when reading a file. It is originally solved in my previous post reading-files-with-multiple-delimiter-in-column-headers-and-skipping-some-rows thanks to @piRsquared When I looked in detail to my real data I realized that some columns have .cd or .dvd extensions and when I applied the solution above they are also separated as a new column and the solution above started not to work! b.txt skip1 A1| A2 |A3 |A4# A5# A6 A7| A8 , A9 1,2,3,4,5.cd

Using python to split a string with delimiter, while ignoring the delimiter and escape quotes inside quotes

﹥>﹥吖頭↗ 提交于 2019-12-22 14:59:35
问题 I am trying to split a string based on the location of a delimiter (I am trying to remove comments from Fortran code). I can split using ! in the following string: x = '''print "hi!" ! Remove me''' pattern = '''(?:[^!"]|"[^"]*")+''' y = re.search(pattern, x) However, this fails if the string contains escape quotes, e.g. z = '''print "h\"i!" ! Remove me''' Can the regex be modified to handle escape quotes? Or should I not even be using regexps for this sort of problem? 回答1: Here's a proven

Extract data between two delimiters

走远了吗. 提交于 2019-12-22 13:56:34
问题 I just want to know whether it is possible to pick up the data that is present between two delimiters (delimiter being a string). For example the original string is as under <message%20type%3D"info"%20code%3D"20005">%20<text>Conference%20successfully%20modified</text>%20<data>0117246</data>%20%20</message>%20 and I want the data that is present between <text> tags. The string from which i need the data can be different. The string can also be like this <message%20type%3D"info"%20code%3D"20001

bash “read -a” looping on null delimited string variable

旧时模样 提交于 2019-12-22 11:25:10
问题 I've been reading up on this post: bash "for in" looping on null delimited string variable to see if I would be able to handle arbitrary text containing spaces inside an array. Based on the post above this works fine: while IFS= read -r -d '' myvar; do echo $myvar; done < <(find . -type f -print0) To check my understanding I also did this (which still works fine): while IFS= read -r -d '' myvar; do echo $myvar; done < <(printf "%s\0" 'a b' 'c d') However, then I attempt storing the output in

PHP preg_split with two delimiters unless a delimiter is within quotes

﹥>﹥吖頭↗ 提交于 2019-12-22 10:57:41
问题 Further on from my previous question about preg_split which was answers super fast, thanks to nick; I would really like to extend the scenario to no split the string when a delimiter is within quotes. For example: If I have the string foo = bar AND bar=foo OR foobar="foo bar" , I'd wish to split the sting on every space or = character but include the = character in the returned array (which works great currently), but I don't want to split the string either of the delimiters are within quotes