Questions tagged [removing-whitespace]

For issues related to removing additional blank-characters like spaces, tabs and new lines or issues related to removing unwanted whitespace.

Related tags:

756 questions
22
votes
2 answers

Oracle trim whitespace on the inside of a string

I am storing phone numbers as VARCHAR2 in my system to allow for users to input '+' characters infront of their phone number if they so choose. My regexp allows for this perfectly, but when storing the number in the database I want to strip out all…
Halfpint
  • 3,967
  • 9
  • 50
  • 92
22
votes
6 answers

remove whitespace in std::string

In C++, what's an easy way to turn: This std::string \t\tHELLO WORLD\r\nHELLO\t\nWORLD \t Into: HELLOWORLDHELLOWORLD
Mr. Smith
  • 4,288
  • 7
  • 40
  • 82
21
votes
8 answers

How can I trim whitespace by Velocity

I have a method called render_something which can creates a lot of whitespace, for example: #render_something('xxx') The result can be: something that generate from redner_something …
Surasin Tancharoen
  • 5,520
  • 4
  • 32
  • 40
21
votes
3 answers

Removing more than one white-space

So, If I have a string like "hello what is my name" How can I take all of the spaces and replace each with only one space?
ThinkingInBits
  • 10,792
  • 8
  • 57
  • 82
20
votes
4 answers

How to remove whitespace from right end of NSString?

This removes white space from both ends of a string: NSString *newString = [oldString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; How do I remove white space from just the right end of a string? UPDATE: The…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
20
votes
4 answers

git - trim whitespace

I've accidentally put some whitespace in my initial commit - it shows up red in git diff --color. What's the best way to get rid of the existing whitespace and how can I avoid this happening again? I am not necessarily looking for a built-in git…
Zaz
  • 46,476
  • 14
  • 84
  • 101
16
votes
5 answers

Delete whitespace in each begin of line of file, using bash

How i can delete whitespace in each line of file, using bash For instance, file1.txt. Before: gg g gg g t ttt after: gg g gg g t ttt
G-71
  • 3,626
  • 12
  • 45
  • 69
16
votes
4 answers

git remove trailing whitespace in new files before commit

I know removing trailing whitespace can be done with a pre-commit hook. I am interested in doing it manually. I read the question here: Make git automatically remove trailing whitespace before committing - Stack Overflow The answer closest to what I…
loop
  • 3,460
  • 5
  • 34
  • 57
15
votes
4 answers

How to remove leading and trailing whitespaces?

I'm using awk '{gsub(/^[ \t]+|[ \t]+$/,""); print;}' in.txt > out.txt to remove both leading and trailing whitespaces. The problem is the output file actually has trailing whitespaces! All lines are of the same length - they are right padded with…
user1194552
  • 151
  • 1
  • 1
  • 4
13
votes
1 answer

Why was the introduction of the `white-space-collapsing` CSS3 property postponed to CSS-text-4 (possibly as `text-space-collapse`)?

During the development of the CSS3 specifiction, the introduction of white-space-collapsing was considered. Such a property would help to solve a nowadays common HTML/CSS problem. Unfortunately, the current CSS3 spec does not contain this property…
Hauke P.
  • 2,695
  • 1
  • 20
  • 43
12
votes
5 answers

Replace space with an underscore

I am trying to write something that will replace all the spaces in a string with an underscore. What I have so far. string space2underscore(string text) { for(int i = 0; i < text.length(); i++) { if(text[i] == ' ') …
Luke Berry
  • 1,927
  • 4
  • 19
  • 32
12
votes
1 answer

Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

Removing trailing white space for all lines has already been answered: How to auto-remove trailing whitespace in Eclipse? However, I haven't been able to try to find a way to do so for only the lines that I edited. Please don't mark this as…
Leo Ufimtsev
  • 6,240
  • 5
  • 40
  • 48
11
votes
2 answers

Shiny nesting a link within a paragraph has unwanted whitespace

I'm building a Shiny app with some dynamically generated HTML which includes a link in mid-sentence. Unfortunately if I use the tags functions to do this, every element has a space around it whether I want it or not. For example, if I wanted to…
Brian Stamper
  • 2,143
  • 1
  • 18
  • 41
11
votes
2 answers

Difference between using Split with no parameters and RemoveEmptyEntries option

I'm checking lines in a given text file. Lines may have random whitespace and I'm only interested in checking the number of words in the line and not the whitespace. I do: string[] arrParts = strLine.Trim().Split(); if (arrParts.Length > 0) { …
seebiscuit
  • 4,905
  • 5
  • 31
  • 47
10
votes
2 answers

Handling \u200b (Zero width space) character in text preprocessing for NLP task

I'm preprocessing some text for a NER model I'm training, and I'm encountering this character quite a lot. This character is not removed with strip(): >>> 'Hello world!\u200b'.strip() 'Hello world!\u200b' It is not considered a whitespace for…
Gino
  • 675
  • 2
  • 10
  • 20
1 2
3
50 51