Jump to content

Remove bytes from string


Recommended Posts

Posted

I have a string with "\00\00\00\00\A6\00". Is there a build in function to remove "\00" or should the approach be using regular expressions? Trim white space function does not remove the bytes.

Posted

I'm a little surprised the native Remove White space doesn't work. I also tried the OpenG remove white space and it didn't remove it. There's alot of over head but I think a simple solution would be to use the String to Byte Array, then use the OpenG Filter Array to remove any zeros, then use the byte array to string.

EDIT: Sorry thought of an easier solution. Use the Search and Replace string, where you search for the 00 and replace with nothing. There is a boolean input to remove all, that needs to be set to true.

Posted

The NULL character isn't white space, much less a printable character, which is why neither of those VIs did (or should) remove it.

Search and Replace is a good way to do it, or if you know your data will always have 4 NULL characters prepended, you could use String Subset, which may garner a performance gain.

  • 2 weeks later...
Posted

In a twist of fate, I was just bitten by this when I was pulling in a null-terminated string from a Windows API call. ;)

post-7489-0-53295100-1313437154.png

These can probably be combined into a single node using alternation, so your regex would be "^[\00]*|[\00]*$".

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.