logo separator

[mkgmap-dev] regex to remove leading 0

From Marko Mäkelä marko.makela at iki.fi on Mon Oct 7 14:15:45 BST 2013

On Mon, Oct 07, 2013 at 03:05:18PM +0200, Felix Hartmann wrote:
>Sorry, for asking this simple question here - but what is the regex
>command to remove a leading 0?

Regular expression patterns do not remove anything. I guess we should 
consider introducing a regular expression substitution action.

>I want to rewrite rcn_ref=04 to rcn_ref=4 - now I could do this with
>rcn_ref=04 {set rcn_ref=4} - but what is the regex to do this for all
>numbers?
>
>(searching for rcn_ref=?4 doesn't work without also hitting 14,24 and so
>on...).

The pattern

rcn_ref ~ ^0+
or
rcn_ref ~ 00*

should take care of the matching part, but I have no idea how it could 
be replaced nicely. One possibility for future syntax could be similar 
to how the Perl pattern-match operator works:

rcn_ref ~ 00*(.*) { set rcn_ref=$1 }

Best regards,

	Marko


More information about the mkgmap-dev mailing list