Questions tagged [trailing]

Trailing characters are characters at the end of a string that should be removed for reason (eg. trailing zeros in "0.5000", trailing spaces in "hello ", trailing slash in a URL, trailing newline character, etc.).

This tag should be used for questions related to strings formatting issues, either when the goal is to parse the string or to display it. However context may be very different from one question to the other, and this tag covers a wide area.

217 questions
2012
votes
27 answers

How can I remove a trailing newline?

How can I remove the last character of a string if it is a newline? "abc\n" --> "abc"
RidingThisToTheTop
826
votes
7 answers

Remove trailing delimiting character from a delimited string

What is fastest way to remove the last character from a string? I have a string like a,b,c,d,e, I would like to remove the last ',' and get the remaining string back: OUTPUT: a,b,c,d,e What is the fastest way to do this?
I-M-JM
  • 15,732
  • 26
  • 77
  • 103
176
votes
15 answers

Remove Trailing Spaces and Update in Columns in SQL Server

I have trailing spaces in a column in a SQL Server table called Company Name. All data in this column has trailing spaces. I want to remove all those, and I want to have the data without any trailing spaces. The company name is like "Amit Tech Corp …
AGM Raja
  • 1,835
  • 2
  • 12
  • 11
173
votes
7 answers

How to remove leading and trailing zeros in a string? Python

I have several alphanumeric strings like these listOfNum = ['000231512-n','1209123100000-n00000','alphanumeric0000', '000alphanumeric'] The desired output for removing trailing zeros would be: listOfNum =…
alvas
  • 115,346
  • 109
  • 446
  • 738
92
votes
11 answers

How do I remove trailing whitespace using a regular expression?

I want to remove trailing white spaces and tabs from my code without removing empty lines. I tried: \s+$ and: ([^\n]*)\s+\r\n But they all removed empty lines too. I guess \s matches end-of-line characters too. UPDATE (2016): Nowadays I automate…
ellockie
  • 3,730
  • 6
  • 42
  • 44
76
votes
3 answers

How to remove trailing zeros from a double

For example I need 5.0 to become 5, or 4.3000 to become 4.3.
Wrath
  • 825
  • 1
  • 6
  • 6
53
votes
6 answers

Swift - Remove Trailing Zeros From Double

What is the function that removes trailing zeros from doubles? var double = 3.0 var double2 = 3.10 println(func(double)) // 3 println(func(double2)) // 3.1
Bogdan Bogdanov
  • 882
  • 11
  • 36
  • 79
51
votes
11 answers

Remove a trailing slash from a string(changed from url type) in JAVA

I want to remove the trailing slash from a string in Java. I want to check if the string ends with a url, and if it does, i want to remove it. Here is what I have: String s = "http://almaden.ibm.com/"; s= s.replaceAll("/",""); and this: String s…
Eswar Rajesh Pinapala
  • 4,841
  • 4
  • 32
  • 40
37
votes
10 answers

How to turn off the prettier trailing comma in VS Code?

How to turn off the prettier trailing comma in VS Code? I go to settings. Select none for the prettier trailing comma. Restart VS Code. Select a piece of TypeScript, press Ctrl + Shift + F and the trailing commas still appear. How could I fix it?
manymanymore
  • 2,251
  • 3
  • 26
  • 48
33
votes
5 answers

Do any browsers support trailers sent in chunked encoding responses?

HTTP/1.1 specifies that a response sent as Transfer-Encoding: chunked can include optional trailers (ie. what would normally be sent as headers, but for whatever reason can't be calculated before the content, so they can be appended to the end), for…
Scott
  • 1,518
  • 1
  • 15
  • 23
29
votes
1 answer

JavaScript - Keep trailing zeroes

I want to parse a string and I used parseFloat(), but it removes all the trailing zeroes. How to prevent this - I need to parse the string exactly - if I have 2.5000, I need exactly the same result as a floating-point number - 2.5000.
Isadora
  • 423
  • 1
  • 5
  • 12
26
votes
8 answers

Bash: find files with trailing spaces at the end of the lines

I'm looking for a bash command to find files with trailing spaces at the end of each line. I'm not interested in removing the spaces, but just in finding the files.
tirenweb
  • 30,963
  • 73
  • 183
  • 303
19
votes
7 answers

Simple URL routes in WCF Rest 4.0 without trailing slash

I have a WCF REST 4.0 project based on the the WCF REST Service Template 40(CS). I'd like to expose simple service endpoint URLs without trailing slashes. For example: CarService.cs http://www.domain.com/cars - GET returns a list of all…
Will
  • 375
  • 1
  • 4
  • 13
17
votes
4 answers

datetime strptime - set format to ignore trailing part of string

I have a string with variable length and I want to give a format to strptime in order for the rest of the string to be ignored. Let me exemplify. I have something like 9/4/2013,00:00:00,7.8,7.4,9.53 10/4/2013,00:00:00,8.64,7.4,9.53 and I want a…
TomCho
  • 3,204
  • 6
  • 32
  • 83
13
votes
5 answers

Laravel model Trailing Data when save the model

I have some code like this $editStuState = StuAtt::where('studentId' , '=' , $id)->first(); $editStuState -> leave +=1; $editStuState -> present = $editStuState -> present-1; $editStuState->update(); //OR …
Nasser Ali Karimi
  • 4,462
  • 6
  • 34
  • 77
1
2 3
14 15