News:

Welcome on our forum!

Main Menu

leading zeros

Started by dafrenchman, August 12, 2020, 04:44:59 PM

Previous topic - Next topic

dafrenchman

Allo,

Is there a way to remove leading zeros in a parsed string item?
I think maybe via expressions plugin?

Example

0088-190031 should become 88-190031

Thanks,
                                                                                                                                                                                                                                                                                                                                                                       

Arthur Grasin

Hello,

Could you please show me your full data packet. It is possible, you may use a regular expression to extract data as you want.

Otherwise, you should use the "Script execute" plugin.
If you like my work, please take a few seconds and add feedback about our site or our software [here]

dafrenchman

#2
Allo,

Below are 2 data packets. with desired results.

First sample

?880698-00-2061    28103@
need to parse as
field 1           880698-00-2      (11 characters)
field 2           061                   (3 characters)
field 3           28103                (up to 9 characters)


Second sample

?0088-190031061    28230@
need to parse as
field 1           88-190031         (9 characters with first leading 0 dropped)
field 2           061                    (3 Characters)
field 3           28230                (up to 9 characters)


I hope this can be done.

Thanks.

Arthur Grasin

Try the following:

Sart signature: ?
End signature: @
Parse full data packet: yes

The regular expression for the first variable:

\?0*([\d\-]+)\d{3}\ {3}

The regular expression for the second variable:

(\d{3})\ {3}

The regular expression for the 3rd variable:

(\d+)\@
If you like my work, please take a few seconds and add feedback about our site or our software [here]

dafrenchman

Thank you.

Just to make sure I understand.
This would be used in the expressions plugin?

CB

Arthur Grasin

You should use it in the ASCII Data Parser plugin.
If you like my work, please take a few seconds and add feedback about our site or our software [here]