View Single Post
Old 06-19-2015, 04:46 PM   #5
lina.w
Junior Member
lina.w began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jan 2015
Device: none
Quote:
Originally Posted by eschwartz View Post
I guess you could then regex the number to strip trailing zeroes and periods. But that might require raising the complexity to a General Program Mode template -- I believe formatting comes after functions.

So:

Code:
program:

formatted_series = finish_formatting(
    field('series_index'),
    '4.1f',
    '',
    ''
);
stripped_series = re(
    formatted_series,
    '^ \[(.*)[.0]+\]$',
    ' [\1] '
);

# Add together the final result
strcat(
    field('series'),
    stripped_series,
    field('title')
);
Good thing I've learned regex last semester so I can understand what is going on! Hmmm...I've pretty much copied and pasted the code you provided to the template, but this still doesn't change [01.0] to [01].

Do you mind explaining to me what '^ ' and '$' from '^ \[(.*)[.0]+\]$' does? If I remember correctly, ^ means negate? I'm not quite sure what the $ at the end does though.

Also, do we not need to escape the brackets from ' [\1] '?

Sorry for asking so many questions!

Last edited by lina.w; 06-19-2015 at 04:50 PM.
lina.w is offline   Reply With Quote