"strip" refers to the process of removing (stripping) certain characters from a string. A common example is removing trailing whitespace characters.
Questions tagged [strip]
1330 questions
-2
votes
1 answer
Striping & Removing numbers in a Set
I have a simple set that contains strings and some of those strings are numbers. (i.e. '1', '45', '5', '39').
Some of the strings have dashes (-) or plus (+) signs in them. (i.e. '55+', '1-3').
I have created a function that should parse the set…

kstullich
- 651
- 1
- 11
- 27
-2
votes
1 answer
strip remaining portion after one word in a string
I need to strip remaining portion after the word "STOP" in a string
Example 1:
Input: "Hello STOP CAN NOT BE"
output: "CAN NOT BE"
Example 2:
Input : "OK PLEASE STOP THERE"
Output : `THERE"
Can somebody help this in JavaScript or grooovy script…

VichuCoder
- 21
- 3
-2
votes
1 answer
Python: how to get the related lines from file?
How can I get the related lines from a file?
This is my code:
read_file = "a.txt"
read_batch = "b.txt"
lines_batch = list()
with open(read_file) as r:
bigstat = r.read()
with open(read_batch) as b:
for batch in (line_batch.strip()…

muc777
- 37
- 7
-2
votes
1 answer
Recommend Freeware/OpenSource programs to strip all styling (or selectively)
Longtime lurker, first post. Oh and for the record, I am most definitely not a programmer. :)
I'm looking for freeware that will allow me to strip — all, or selectively — the styling in an HTML document. Please recommend your favorites. Thanks.

semicodin
- 19
- 8
-2
votes
2 answers
Python code, .rstrip isn't working?
I've searched answers on here and tried implementing them but I think that there is some tiny detail I'm missing. I have a very short python code for a program that is supposed to return the initials with periods of a persons input(for their full…
-2
votes
4 answers
How do I remove commas and quotations from my list output
Having a hard time stripping these quotation marks and commas from my list,
**SHOWN BELOW IN THE SECOND PART OF MY CODE OUTPUT**I need all of the (' ',) to be stripped from the output and I keep trying the rstrip() on my team variablebut it is…

Slow Poke
- 131
- 1
- 14
-2
votes
2 answers
Remove all except inside tag
How to remove all from page except text inside
tag? Page: This is text.
This is text in 'div' tag
This is text in 'p' tag
Expected result: This is text in 'p' tag Greetings.
J. Doe
- 1
-2
votes
1 answer
Extracting a part of a string in php
I have a specific need to strip characters from a PHP input.
For example, we have a version number and I only need the last part of it.
Given 14.1.2.123 I only need 123
Given 14.3.21 I only need the 21
Is there a way that I can get just those…

Adrian Stoker
- 29
- 3
-2
votes
2 answers
Python strip() not working inside a function
I am trying to use strip() to trim off the space before and after a string. It works fine for
str1 = " abdced "
str1.strip()
However when I use it inside a function, it is not working:
def func(str1):
return str1.strip()
print func(" …

Christine Cheng
- 49
- 1
- 1
- 2
-2
votes
1 answer
Why str.lstrip will truncate letter e for words beginning with e but not for other letters?
Strangely I met with this problem when I was trying to take out contents from an excel file with Python using xlrd modulus.
The example is like below:
Python 2.7.6 (default, Mar 22 2014, 22:59:38)
[GCC 4.8.2] on linux2
Type "help", "copyright",…

sikisis
- 458
- 9
- 21
-2
votes
1 answer
Python2.7: Too many Values to Unpack - Number of Columns unknown
I have a file that I want to unpack and utilise the columns in different files. The issue I have is that the file I want to unpack varies from row to row on the number of columns it has (for example row 1 could have 7 columns, row 2 could have…

user2320229
- 71
- 1
- 7
-2
votes
2 answers
python re prevent stripping whitespaces
:)
I'm not sure why the following python code removes whitespaces too, but it does.
Could someone please explain how I could pull this off without it doing so?
Thank you ! :)
text = html
rules = [
{ r'>\s+' : u'>'},
{ r'\s+' : u' '},
{…

abkai
- 591
- 2
- 6
- 18
-3
votes
1 answer
Why does Python's rstrip remove more characters than expected?
According to the docs the function will strip that sequence of chars from the right side of the string.
The expression 'https://odinultra.ai/api'.rstrip('/api') should result in the string 'https://odinultra.ai'.
Instead here is what we get in…

Corneliu Maftuleac
- 438
- 4
- 14
-3
votes
2 answers
Strip function not working in a list in python
I'd like to remove white spaces before & after each word in a list
with open(r"C:\filelocation") as f:
lines = f.readlines()
for i in lines:
i = i.strip()
i= i.split(",")
When I print my list, I get the following
['46', 'Celsius …

Ash S
- 119
- 5
-3
votes
1 answer
can somone explain me how this code checks if a word is uppercase
Here is the code and im struggling to understand the line 5 and 6.
I know how isupper() works but i cant understand the combinations going on.
def IndexWords(InputText):
words = 0
count = 2
for i in range(len(InputText)):
for…

Elsahn_go
- 1
- 1