Format text but add empty space if hour is less than 4 characters

Follow-up to this question:

How to format the following text so if the time is, say, 9:00am, it adds an empty space at the beginning? While also aplying this same format to the Second column, AND also the keep text aligned at the end?

⠀⠀⠀⠀⠀⠀

Input:

8:00am - 10:00am Working, saw video of people with Cat filter on on video
7:00am - 9:00am Working
9:00am - 11:00am Meeting with people I hate
11:00am - 11:30am Meeting
11:30am - 12:30pm Meeting
12:30pm - 1:00pm Working
2:00pm - 5:00pm Working

⠀⠀⠀⠀⠀⠀

Output:

 8:00am - 10:00am ......... Working, saw video of people with Cat filter on on video
 7:00am -  9:00am ......... Working
 9:00am - 11:00am ......... Meeting with people I hate
11:00am - 11:30am ......... Meeting
11:30am - 12:30pm ......... Meeting
12:30pm -  1:00pm ......... Working
 2:00pm -  5:00pm ......... Working

⠀⠀⠀⠀⠀⠀

Example, I enter:

8:00am - 10:00am Working, saw video of people with Cat filter on on video

and output would be:

𝍖8:00am - 10:00am ......... Working, saw video of people with Cat filter on on video

Where 𝍖 is the SPACE character.
⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀

Used this script from CCStone:

#!/usr/bin/env perl -0777 -nsw
use v5.12;
use utf8;

s!\A\s+|\s+\Z!!gm;							# Remove leading and trailing \v whitespace.
s!^\h+|\h+$!!gm;							# Remove leading and trailing \h whitespace.
s!\h+(Working|Meeting)!\t$1!g;				# Emplace tab delimiter for . leader.
s!^(.+?)\t!$1.' '.('.' x (20 - length $1)).' '!mge;		# Emplace dot leaders.
print;									# Print output.

⠀⠀⠀⠀⠀⠀

Thanks

Add a find/replace line to my script to do the appropriate thing with a single leading digit.

-Chris

yes, so simple!

This seems to work:

#!/usr/bin/env perl -0777 -nsw
use v5.12;
use utf8;

s!\A\s+|\s+\Z!!gm;							# Remove leading and trailing \v whitespace.
s!^\h+|\h+$!!gm;							# Remove leading and trailing \h whitespace.
s/(\b\d:)/ $1/g;							# Find digit, replace with space+digit
s!\h+(Working|Meeting)!\t$1!g;				# Emplace tab delimiter for . leader.
s!^(.+?)\t!$1.' '.('.' x (20 - length $1)).' '!mge;		# Emplace dot leaders.
print;									# Print output.
1 Like