Semi-Autocrop PDF using Inkscape command line

Programs intend to save a whole page for everything that is saved as PDF, even if the content just takes 5% of a page. If you then have to crop a large batch of PDFs manually it is really a pain, but Inkscape offers a nice way to do this using the command line.

Continue reading “Semi-Autocrop PDF using Inkscape command line”

Range in Regular Expressions

While searching for ranges in regular expressions I found this page: The page generates regular expressions for ranges and works really nice. You want for example a regex for the range 12 to 389 and the page generates this for you: 


Unfortunately negative values are not allowed. But I needed to have an regex for the range between -128 and 127. If you also need something like this to define types like short or byte, there is a nice trick.

  1. generate the regex from 0 to 128: ^([0-9]{1,2}|1[01][0-9]|12[0-8])$
  2. add an optional – in the beginning: ^[-]?([0-9]{1,2}|1[01][0-9]|12[0-8])$
  3. exclude 128: ^(?!128)[-]?([0-9]{1,2}|1[01][0-9]|12[0-8])$

And there you have it, a range regex for values from -128 to 127.