Example Code

Remove Trailing Space from String

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

 

Overview
This VI can be used as a subVI to remove a trailing space from a string.


Description
A trailing space is a space following the last character of a string. For example, "test " contains a trailing space, but "test" does not. Running this VI would convert "test " to "test" by removing the trailing space.This sub VI in a For Loop to remove trailing spaces from each string in the array.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Input a string
  1. Run VI

 

 

Additional Information or References
VI Block Diagram

 Block Diagram.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
crossrulz
Knight of NI Knight of NI
Knight of NI
on

What's wrong with just using the built in Trim White Spaces?  There is an option to have it only trim the end.  This way you can remove multiple spaces that are trailing (which I have ran into plenty of times).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Daniel_H1
Member
Member
on

Hi crossrulz,

The built-in Trim Whitespace VI will remove all spaces, tabs, carriage returns, and linefeeds. There are times when you may want to cycle through many strings and remove the spaces, but leave tabs or carriage returns at the ends of other strings. Basically, this gives you a little more specificity.