Questions tagged [string]

A string is a sequence of zero or more characters. It is commonly used to represent text or a sequence of bytes. Use this tag along with the appropriate programming language being used.

213 questions
124
votes
6 answers

Formatting a comma-delimited CSV to force Excel to interpret value as a string

I've been searching around for a while trying to figure out how to output a CSV file in such a way to force Excel to interpret the values as a string and not try to convert them to numbers or dates. e.g.: "141", "10/11/2002", "350.00",…
Simon E.
  • 3,841
  • 5
  • 29
  • 31
28
votes
4 answers

How do you escape apostrophe in single quoted string in bash?

I don't understand how bash evaluates escaping of apostrophe characters in single quoted strings. Here is an example: $ echo ''\''Hello World'\''' 'Hello World' # works $ echo '\'Hello World\'' > # expects you to continue input I've tried looking…
Kibet
  • 418
  • 1
  • 4
  • 9
22
votes
5 answers

Excel extract substring from string

I am looking for a way to extract a variable length substring from a string. My cells will look something like: ABC - DEF ABCDE - DEF ABCD - ABC I want to split the string at the - character, so the cells will become: ABC ABCDE ABCD This should be…
Pieter van Niekerk
  • 703
  • 4
  • 11
  • 24
22
votes
4 answers

Any Excel function that will reverse a string?

Are there any built-in Excel functions that will reverse a string?
mindless.panda
  • 7,262
  • 13
  • 47
  • 66
18
votes
7 answers

How to split a string with quotes (like command arguments) in bash?

I have a string like this: "aString that may haveSpaces IN IT" bar foo "bamboo" "bam boo" I want to be able to split it like this: aString that may haveSpaces IN IT bar foo bamboo bam boo How do I do that? (preferrably using a one-liner)
foxneSs
  • 283
  • 1
  • 2
  • 6
16
votes
6 answers

Excel CSV import treating quoted strings of numbers as numeric values, not strings

I've got a web application that is exporting its data to a CSV file. Here's one example row of the CSV file in question: 28,"65154",02/21/2013 00:00,"false","0316295","8316012,8315844","MALE" Since I can't post an image, I'll have to explain the…
Michael Oryl
  • 287
  • 1
  • 2
  • 8
14
votes
3 answers

Excel: Replace occurences of one character with another in a String?

I want an excel formula that will change Haverford, PA to haverford,+pa. (Text is to lowercase, and spaces are replaced with plus characters.) The following will get the first space, but not all of them: =REPLACE(E19, SEARCH(" ", E19),1,"+")
Nick Heiner
  • 1,602
  • 8
  • 26
  • 35
13
votes
8 answers

Bash Script to repeat every word in a line?

I have a string like: dog cat bird whale And I want to get dog dog cat cat bird bird whale whale All the words are in the same line. Any idea?
Cristian
  • 131
  • 1
  • 5
10
votes
3 answers

Using vim to delete all lines except those that match an arbitrary set of strings

I use vim to remove all lines except those that match a particular string, e.g. :g!/[string that I want to remain in the editor]/d Works great. But what I really want, and haven't found anywhere, is a way to use vim to remove all except for…
Dave
  • 332
  • 3
  • 9
  • 19
7
votes
5 answers

Excel Cell Length Limit

Excel is refusing to open some of the files I programmaticaly create. I think what is happening is that it pukes because a particular column has very long strings (up to 1850 chars), but for the purposes of troubleshooting when I make the strings…
rlb.usa
  • 1,518
  • 5
  • 20
  • 32
7
votes
3 answers

Insert quote into string variable in bash

Is there way of inserting a quote at the start and end into a string variable? I have this variable say: string="desktop/first folder" If I echo this, it will display: desktop/first folder I need the string to be stored as: "desktop/first folder"
Ali Gul
  • 73
  • 1
  • 1
  • 3
6
votes
1 answer

awk - awk concatenate string variable

I would like to awk concatenate string variable in awk. How can I do that? I tried: BEGIN{ t="." r=";" w=t+r print w} But I does't work. Output: 0 Or I want to add variable and result of function. Input: t t t t a t a ta ata ta a…
diego9403
  • 897
  • 1
  • 12
  • 21
6
votes
4 answers

awk match whole word

I want to use awk to match whole words from text file. Including words bounded by non alphanumeric characters. For example - string to search for - ABC Source file - HHHABCCCCH HHH ABC HH(ABC)ASDAASD HH,ABC-ASASDASD Result - HHH…
bryan
  • 8,400
  • 4
  • 28
  • 41
5
votes
1 answer

Can I force an Excel 2010 Pivot-Table to display text strings from my raw data?

Here is my use-case. As a training specialist I want to look at a single tab in Excel and see student feedback at a glance. I want to see pie-charts showing who said "Yes" this course was a good use of my time and "No" this was not a good use of my…
Kevin Taylor
  • 51
  • 1
  • 1
  • 2
4
votes
2 answers

How to concat String, File Contents, and String in bash script?

I have a file which contains only one line $> cat file.txt apple,orange,cat,dog I need to append two String to it and assign it to a variable, one in front and another in the end, so that it becomes: var=key,apple,orange,cat,dog,ending so that I…
FGH
  • 41
  • 1
  • 1
  • 2
1
2 3
14 15