For example, let's say I want to delete from the array all continuous segments of 0's longer than 3 bytes
byte a[] = {1,2,3,0,1,2,3,0,0,0,0,4};
byte r[] = magic(a);
System.out.println(r);
result
{1,2,3,0,1,2,3,4}
I want to do something like a regular expression in Java, but on a byte array instead of a String.
Is there something that can help me built-in (or is there a good third party tool), or do I need to work from scratch?
Strings are UTF-16, so converting back and forth isn't a good idea? At least it's a lot of wasted overhead ... right?
解决方案
regex is not the tool for the job, you will instead need to implement that from scratch