Is it possible to left pad a matched group?
Here is my situation. I am working on a program to integrate inventory from my companies warehouse with our website.
Our part numbers in our Warehouse inventory look like this:
1501895, 1000973, 5000165, 6000002, etc.
On our website, these same numbers would look like this:
15-1895, 1-973,5-165, 6-02
My program monitors our warehouse inventory database for changes, and when a change is made it needs to find the matching item on our website.
This is the code that I originally used:
StringRegExpReplace($new_items[$i][0],"([1-9]{1,2})(0*)(\d{1,4})","$1-$3")
However I noticed this does not work for numbers that match my last example. The last matched group needs to be zero padded if the number is less than 10.
Does anyone have an idea of where to start for this? Is there a better way than how I have started?