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.

214 questions
143
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.
  • 4,345
30
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
  • 438
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…
22
votes
4 answers

Any Excel function that will reverse a string?

Are there any built-in Excel functions that will reverse a string?
20
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
  • 303
17
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…
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,642
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
11
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
  • 362
10
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
  • 103
8
votes
1 answer

What is the << EOF equivalent in powershell

What is the powershell equivalent to the Linux command: tee file.txt < would be something like: blah blah <\n> beh ble <\n> EOF Let's say that I copy the 3 lines above, and then enter some (yet-unknown) powershell…
not2qubit
  • 2,651
  • 4
  • 34
  • 45
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,548
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
  • 917
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,528
  • 4
  • 30
  • 42
6
votes
1 answer

Use findstr to Search a Sub Directory for a String?

I can use the following to search for text files that contain the word "string" from the Windows Command Prompt: C:\>findstr /spin /c:"string" *.txt What if I want to search a sub-directory? The following doesn't work: C:\>findstr /spin…
GTS Joe
  • 281
1
2 3
14 15