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
7
votes
2 answers

Why does my Javascript trim Function not work?

I am using this function to build a pig latin translator and seem to have everything figured out except for the .trim() part. What should I do different? function ParseText() { var myText = "asdf\n hat\n cat dog\n apple"; var lines =…
jth41
  • 3,808
  • 9
  • 59
  • 109
6
votes
6 answers

replace substring of matched regex

I fetch some html and do some string manipulation and en up with a string like string sample = "\n \n 2 \n \n \ndl. \n \n \n flour\n\n \n 4 \n \n cups of \n\nsugar\n" I would like to find all ingredient lines and remove…
Flexo
  • 2,506
  • 3
  • 21
  • 32
6
votes
0 answers

Visual Studio Code trimTrailingWhitespace set to false is still trimming whitespace on save

I've been using VS Code for about three months now. I have this issue where I update one single line of code in a .js file (also happens with some .css files) and my diff tool tells me that there are 100s of changes. Apparently the…
6
votes
1 answer

Elasticsearch "pattern_replace", replacing whitespaces while analyzing

Basically I want to remove all whitespaces and tokenize the whole string as a single token. (I will use nGram on top of that later on.) This is my index settings: "settings": { "index": { "analysis": { "filter": { "whitespace_remove":…
6
votes
2 answers

Ignoring whitespace (in certain parts) in Antlr4

I am not so familiar with antlr. I am using version 4 and I have a grammar where whitespace is not important in some parts (but it might be in others, or rather its luck). So say we have the following grammar grammar Foo; program : A* ; A : ID '@'…
George Kastrinis
  • 4,924
  • 4
  • 29
  • 46
6
votes
4 answers

Remove Space at end of String but keep new line symbol

How can I check if a Python string at any point has a single space before new line? And if it does, I have to remove that single space, but keep the new line symbol. Is this possible?
user4593086
6
votes
2 answers

How to git-add only non-whitespace changes and new files?

We can do diff with some types of ignoring whitespaces: 1) git diff --ignore-space-at-eol # Ignore changes in whitespace at EOL. 2) git diff --ignore-space-change / git diff -b # Ignore changes in amount of whitespace. 3) git diff…
user1742529
  • 260
  • 4
  • 16
6
votes
5 answers

Regex: How to remove extra spaces between strings in Perl

I am working on a program that take user input for two file names. Unfortunately, the program can easily break if the user does not follow the specified format of the input. I want to write code that improves its resiliency against these types of…
cooldood3490
  • 2,418
  • 7
  • 51
  • 66
5
votes
4 answers

How to trim blank spaces from PowerShell output?

I am using a PowerShell script to find all occurrences of a regex expression and output it to file. I have two objectives for this question. Remove leading white space from a column's value Specify a width for an extra field (LineNumbers) This is…
xcodr
  • 1,177
  • 2
  • 14
  • 26
5
votes
2 answers

How do I replace sequences of whitespaces by one space but don't trim in XSLT?

The function normalize-space removes leading and trailing whitespace and replaces sequences of whitespace characters by a single space. How can I only replaces sequences of whitespace characters by a single space in XSLT 1.0? For instance…
Jakob
  • 3,570
  • 3
  • 36
  • 49
5
votes
2 answers

Quickly remove unnecessary whitespace from a (very large) string

I'm working with very large (45,000,000+ character) strings in VBA, and I need to remove superfluous whitespace. One space (aka, ASCII Code 32) is okay but any sections with two or more consecutive spaces should be reduced to only one. I found a…
ashleedawg
  • 20,365
  • 9
  • 72
  • 105
5
votes
2 answers

how to remove the whitespace below the bootstrap progress bar

How can I remove or minimize the gap in between progress bar and string: