How to trim leading zeros of CAS#

Hi all,

I have a table of CASRNs in a column named "CASNO".  Because of how the outside program outputs CAS#'s they end up padded by leading zeros to a constant length.  For example 50-00-0 is represented as 0000050-00-0.  Depending on the length of the CAS number there can be one or 5 leading zeros.

Can I use the Java snippet (simple) node to remove the leading zeors?  If so, can somebody help me assign the correct terms in the Global Variable Declaration and Method Body?

I am failing miserably due to lack of Java knowledge.  I was not able to find the exact solution using the search function on the forum.




the workflow in attachment will give you the answer.

Best regards


Hi Fabien,

That is similar to what I was trying-- however, that expression won't run on my version 2.11.  I get the following error:

The method regexReplace(java.lang.String, java.lang.String, java.lang.String) is undefined for the type Expression32

I suspect there is a Java preference that needs to be selected in "Preferences" or a Java file that needs to be copied.  Any ideas?


Thanks again,




Hi Drewb4,

If it can help I'm working with a 2.11.2 under windows 7 64 bit. A good challenge for the wonderful development team ?



I haven't looked at Fabiens workflow, but my guess would be to use RegExpression in the String Replacer node with the pattern expression


And for replacement text it would be



I don't know if this helps.


Simon-- that worked!  Thanks!