Questions tagged [strip]

"strip" refers to the process of removing (stripping) certain characters from a string. A common example is removing trailing whitespace characters.

1330 questions
106
votes
4 answers

What is the difference between "gcc -s" and a "strip" command?

I wonder what is the difference between these two: gcc -s: Remove all symbol table and relocation information from the executable. strip: Discard symbols from object files. Do they have the same meaning? Which one do you use to: reduce the…
Tim
  • 1
  • 141
  • 372
  • 590
105
votes
5 answers

How to strip type from Javascript FileReader base64 string?

I've got the following code in my Javascript: var reader = new FileReader(); reader.onloadend = function () { alert(reader.result); }; This shows me the following data: …
kramer65
  • 50,427
  • 120
  • 308
  • 488
95
votes
6 answers

Vim run autocmd on all filetypes EXCEPT

I have a Vim autocmd that removes trailing whitespace in files before write. I want this almost 100% of the time, but there are a few filetypes that I'd like it disabled. Conventional wisdom is to list the filetypes you want an autocmd to run…
jerodsanto
  • 9,726
  • 8
  • 29
  • 23
95
votes
4 answers

How to strip comma in Python string

How can I strip the comma from a Python string such as Foo, bar? I tried 'Foo, bar'.strip(','), but it didn't work.
msampaio
  • 3,394
  • 6
  • 33
  • 53
90
votes
9 answers

How to strip a specific word from a string?

I need to strip a specific word from a string. But I find python strip method seems can't recognize an ordered word. The just strip off any characters passed to the parameter. For example: >>> papa = "papa is a good man" >>> app = "app is…
Zen
  • 4,381
  • 5
  • 29
  • 56
62
votes
7 answers

python: rstrip one exact string, respecting order

Is it possible to use the python command rstrip so that it does only remove one exact string and does not take all letters separately? I was confused when this happened: >>>"Boat.txt".rstrip(".txt") >>>'Boa' What I expected…
aldorado
  • 4,394
  • 10
  • 35
  • 46
57
votes
15 answers

Best way to automatically remove comments from PHP code

What’s the best way to remove comments from a PHP file? I want to do something similar to strip-whitespace() - but it shouldn't remove the line breaks as well. For example, I want this:
benlumley
  • 11,370
  • 2
  • 40
  • 39
54
votes
16 answers

Removing leading zeros before passing a shell variable to another command

It turns out that iptables doesn't handle leading zeros too well. As $machinenumber that is used has to have a leading zero in it for other purposes, the idea is simply to create a new variable ($nozero) based on $machinenumber, where leading zeros…
Jarmund
  • 3,003
  • 4
  • 22
  • 45
50
votes
10 answers

strip decimal points from variable

I have a series of variables that have a decimal point and a few zeros. How do I strip the variable so it goes from 1.000 to 1?
Zac
  • 12,637
  • 21
  • 74
  • 122
48
votes
5 answers

String.strip() in Python

While learning about python, I came upon this code, which takes a text file, splits each line into an array, and inserts it into a custom dictionary, where the array[0] is the key and array[1] is the value: my_dict = {} infile =…
Rhs
  • 3,188
  • 12
  • 46
  • 84
45
votes
6 answers

Delete first 3 characters and last 3 characters from String PHP

I need to delete the first 3 letters of a string and the last 3 letters of a string. I know I can use substr() to start at a certain character but if I need to strip both first and last characters i'm not sure if I can actually use this. Any…
Howdy_McGee
  • 10,422
  • 29
  • 111
  • 186
44
votes
5 answers

How to strip executables thoroughly

I'd like to strip as much as I can - on Linux: an ELF. I only want in there the stuff I need to run it. I tried using strip: strip --strip-all elf But it doesn't seem to do a good job: nm still displays lots of stuff, and the binary is still…
peoro
  • 25,562
  • 20
  • 98
  • 150
43
votes
6 answers

Stripping linux shared libraries

We've recently been asked to ship a Linux version of one of our libraries, previously we've developed under Linux and shipped for Windows where deploying libraries is generally a lot easier. The problem we've hit upon is in stripping the exported…
Adam Bowen
  • 10,820
  • 6
  • 36
  • 41
40
votes
1 answer

gcc -g vs not -g and strip vs not strip, performance and memory usage?

If binary file size is not an issue, are there any drawbacks using -g and not strip binaries that are to be run in a performance critical environment? I have a lot of disk space but the binary is cpu intensive and uses a lot of memory. The binary is…
Johan
  • 5,003
  • 3
  • 36
  • 50
38
votes
4 answers

How to disassemble the main function of a stripped application?

Let's say I compiled the application below and stripped it's symbols. #include int main() { printf("Hello\n"); } Build procedure: gcc -o hello hello.c strip --strip-unneeded hello If the application wasn't stripped, disassembling…
karlphillip
  • 92,053
  • 36
  • 243
  • 426
1
2
3
88 89