From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete White Space in Strings

My project involves reading databases of strings and numbers. The
database is not flexible (I can't control what the variable names are
and more importantly, what the spacing is). I am trying to search the
database for certain variable names in a systematic way. Unfortunately
the number and location of blank spaces inconsistent, I would like to
be able to strip the strings of all white space. Is there a built in
function that I can use? Has anyone ever done anything similar? I'm
at a loss here.

For clarity, I'm looking for a way of deleting all the space characters
from my strings.


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 9
(15,348 Views)
Look at the VI located at Examples\General\Strings.llb\Search String and
Replace - General.vi

Use it to replace spaces with empty string. The input pattern is a regular
expression so you can enter [\s\t\r\n]+ and it will remove all white
characters, spaces, tabs, returns and line feeds

Take a look also to "Match Pattern" and "Scan String for Token" functions.



--
Jean-Pierre Drolet
Scientech R&D inc
Trois-Rivieres-Ouest (Quebec)
CANADA G8Z 4H1




Spencer a écrit dans le message :
8e73m4$9ka$1@nnrp1.deja.com...
> My project involves reading databases of strings and numbers. The
> database is not flexible (I can't control what the variable names are
> and more importantly, what the spacing is). I am trying to search the
> database f
or certain variable names in a systematic way. Unfortunately
> the number and location of blank spaces inconsistent, I would like to
> be able to strip the strings of all white space. Is there a built in
> function that I can use? Has anyone ever done anything similar? I'm
> at a loss here.
>
> For clarity, I'm looking for a way of deleting all the space characters
> from my strings.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Message 2 of 9
(15,348 Views)
Thanks that works great. I appreciate the quick help there.

In article <39071c32@newsgroups.ni.com>,
"Jean-Pierre Drolet" wrote:
>
> Look at the VI located at Examples\General\Strings.llb\Search String
and
> Replace - General.vi
>
> Use it to replace spaces with empty string. The input pattern is a
regular
> expression so you can enter [\s\t\r\n]+ and it will remove all white
> characters, spaces, tabs, returns and line feeds
>
> Take a look also to "Match Pattern" and "Scan String for Token"
functions.
>
> --
> Jean-Pierre Drolet
> Scientech R&D inc
> Trois-Rivieres-Ouest (Quebec)
> CANADA G8Z 4H1
>
> Spencer a écrit dans le message :
> 8e73m4$9ka$1@nnrp1.deja.com...
> > My project involves reading databases of st
rings and numbers. The
> > database is not flexible (I can't control what the variable names
are
> > and more importantly, what the spacing is). I am trying to search
the
> > database for certain variable names in a systematic way.
Unfortunately
> > the number and location of blank spaces inconsistent, I would like
to
> > be able to strip the strings of all white space. Is there a built
in
> > function that I can use? Has anyone ever done anything similar?
I'm
> > at a loss here.
> >
> > For clarity, I'm looking for a way of deleting all the space
characters
> > from my strings.
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 3 of 9
(15,348 Views)

Seach and Replace string with TRUE on replace all input... it should look like this:

 

remove all spaces.png

Message 4 of 9
(13,138 Views)

Wow bogdan,

 

you gave an answer to a 16 years old thread that was already solved…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(13,130 Views)

Indeed "Knight of NI" ...

 

but you should stop being sarcastic with that "wow" ... any contribution to the forum should be appreciated and you should know that.

 

I found this thread searching google ... even if it's 16 years old. I guess other people can do the same and land here with same questions in mind. And for those, I found it more intuitive to have a print screen explaining the sollution than only plain text ... and this is why I added a reply.

 

Best regards,

Bogdan

Message 6 of 9
(13,111 Views)

I doubt Gerd was attempting sarcasm.  That is usually my input to the forumsSmiley Wink  True surprise at a 16 year bump to a thread is more likely the intent of "wow"

 

Trim Whitespace.vi would be a simpler implementation for the OP but, I hope they figured that out over the years. 


"Should be" isn't "Is" -Jay
Message 7 of 9
(13,075 Views)

@JÞB wrote:

Trim Whitespace.vi would be a simpler implementation for the OP but, I hope they figured that out over the years. 


Except they wanted to remove ALL spaces from the stirng, not just the ends.


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
0 Kudos
Message 8 of 9
(13,059 Views)

First...

 

 

Second, resurrecting old threads is generally not necessary especially when they are 15 years, 10 months, 1 week, and 5 days old.  I mean I don't want to date myself too much, but I wasn't in high school when that post was made.  Knights and other LabVIEW celebrities can come across as a bit harsh (myself included) on the forums, but it is partly because we don't need to bring up these old relics, and we want to drive it home to new users, that this generally isn't necessary, especially for topics as simple as this where a single primitive can be used in most cases.  

 

Feel free to read the Unofficial Forum Guidelines if you are interested in a few other ways that this forum prefers the forms of your contributions in.

Message 9 of 9
(13,018 Views)