I have this string (of jeans sizes): W30L30 W31L32 W32L33
And I would like to have W30 31 32
I am trying with
[% SET availableSizes = 'W30L30 W31L32 W32L33' %]
[% regexp = '(?<!^)W|L\d\d+' %]
[% SET availableSizes = availableSizes.replace(regexp , '') %]
But it gives me: 30 31 32
Could you help please?
Contrary to what you claim, your code already produces the desired output.
$ tpage a.tt
W30 31 32
tpage
is the command installed by Template-Toolkit. It's a simple program that processes the specified template using that library. Great for testing :)
a.tt
:
[% SET availableSizes = 'W30L30 W31L32 W32L33' -%]
[% regexp = '(?<!^)W|L\d\d+' -%]
[% SET availableSizes = availableSizes.replace(regexp , '') -%]
[% availableSizes %]
I added [% availableSizes %]
(because your template didn't actually output anything but line feeds) and some -
(to remove the excessive line feeds).