From: Steven Ketcham Date: 2006-09-29T00:51:20+09:00 Subject: Regular expression reformating a value ------=_NextPart_000_004C_01C6E2F3.F4FBA2A0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I am not really sure how to do this. I have a series of number that need parsed. Strip the zeros, if a caret exists replace it with a slash. 1.) 000123^2 - should be 123/2 2.) 1^2 - should be 1/2 3.) 0001 - should be 1 4.) 000123 - should be 123 I do not know how to do the condtional to exclude the slash on examples 3 and 4. How do I prevent the addition of the slash when there is no caret in the number? reg = /(?:[1-9]{1}\d*)\W(?:\d*)/ puts reg.match("000123^2"); puts reg.match("123^2"); puts reg.match("0001"); puts reg.match("000123"); puts reg.match("123"); Thanks! ------=_NextPart_000_004C_01C6E2F3.F4FBA2A0--