04-28-2010 05:30 PM - edited 04-28-2010 05:31 PM
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.
Solved! Go to Solution.
04-28-2010 05:43 PM
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
04-28-2010 05:47 PM
04-28-2010 06:07 PM
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.
04-28-2010 06:08 PM - edited 04-28-2010 06:13 PM
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)
04-28-2010 06:37 PM
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!
04-28-2010 07:02 PM
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.
04-28-2010 07:10 PM
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
04-29-2010 11:08 AM - edited 04-29-2010 11:09 AM
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?
04-29-2010 11:36 AM