LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove whitespace

Solved!
Go to solution

Ok, so I thought this would be simple.  I'm reading in an html file and just want to remove all whitespace.  I'm doing a search and replace on a space constant, tab constant and end on line constant and replacing with an empty string.  Replace all is set to true.  Simple right?  But it doesn't seem to work.  Any ideas?

 

Thanks in advance. 

Message Edited by dubs on 04-28-2010 05:31 PM
0 Kudos
Message 1 of 13
(9,670 Views)

dubs,

 

It looks like you still need to search for linefeeds, "\n".  Try adding another search and replace function with a linefeed constant.

 

Chris M 

0 Kudos
Message 2 of 13
(9,660 Views)
Line feeds and carriage returns should be included in the end of line constant...but even the search and replace on the space constant isn't working.
0 Kudos
Message 3 of 13
(9,656 Views)

By changing the display mode to "\codes", I was able to determine that the spaces and tabs were being removed, but the newline was not being removed.  The raw html text displays newline as "\n".  I think the Labview newline is something like "\r\l" (carraige return & line feed).  This doesn't match \n so those were not removed.  By replacing the newline constant with a string constant, setting the constant to display \codes, and typing in \n, I was able to succesfully remove the newlines from the raw html text.  Try it yourself.

 

newline.png

 

- tbob

Inventor of the WORM Global
Message 4 of 13
(9,646 Views)

dubs wrote:
Line feeds and carriage returns should be included in the end of line constant...but even the search and replace on the space constant isn't working.

 

It is working.  Newlines not being removed make it look like its not working.  Use \codes display to prove it is working.

 

 

Line feed and carriage return is not the same as newline.  carriage return = \r, newline = \n, not sure if line feed has a \code (maybe line feed is same as newline)

 

 

Message Edited by tbob on 04-28-2010 04:12 PM
Message Edited by tbob on 04-28-2010 04:13 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 13
(9,643 Views)

hmm...I think I see my problem. 


The HTML file I'm trying to parse is coming from an Agilent ParBert and they have a bunch of special characters that aren't being included in the search and replace functions.  I’m seeing a bunch of \00 characters that I’m guessing lab view doesn’t count as whitespace...I didn't see them until I turned on the /codes display.  I think this gets me going in the right direction. 

Thanks for the /codes tip!

0 Kudos
Message 6 of 13
(9,625 Views)

Thanks for all the help so far.

 

But I'm still having some issues...searching on a \00 code doesn't seem to work.  Reading through the regexp help I see that "\031 - Matches an octal character (31 octal in this case)"...could this be my problem and is there a way around it?

 

Attached is the data I'm actually dealing with.

0 Kudos
Message 7 of 13
(9,611 Views)

dubs,

 

Make sure that the constant wired to the "search string" input is set to codes display.  Right now, you are searching for the string "\\00", instead of "\00".

 

Chris M 

0 Kudos
Message 8 of 13
(9,607 Views)

That didn't help.  I think the search and replace function is looking for an octal number of "0" Since "\0" as a code is a flag for an octal search. The input string has "\00" which is not an octal representation of a number in my data. 

 

Is there any way to faltten the string from the code display and just do a strict search and replace with ignoring all codes?

Message Edited by dubs on 04-29-2010 11:09 AM
0 Kudos
Message 9 of 13
(9,559 Views)
Solution
Accepted by topic author dubs

Hi dubs,

 

your search string is not configured to display in \codes! Change to \codes and remove the second \, then the replace will work...

Best regards,
GerdW


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