On 2011-05-09, Robert Huttinger wrote:
so the filter doesnt work.. and I am ok at regex, but not at perl, can
someone help me close out this issue?

Seeing an example of your css, we can see the problem. The perl script wasn't expecting NO space after the colon.

So change the script line that is now
       s/([-a-z ]+:)\s+(.+)/sprintf("%-20s",$1) . "$2"/ie;
to
       s/([-a-z ]+:)\s*(.+)/sprintf("%-20s",$1) . "$2"/ie;

The change is because the '+' after \s makes at least one whitespace (denoted by \s) mandatory; using '*' there allows no whitespace as well as multiple whitespaces.

"Whitespace" == spacebar space, tab, return, etc.

If that works, there are some refinements to the sprintf that might get you closer to your original request of attribute at col 4 and value at col 60.

See if this works first, and post again for more.

HTH


so this is the filter:

#! /usr/bin/perl
use strict;
use warnings;
while (<>){
s/([-a-z ]+:)\s+(.+)/sprintf("%-20s",$1) . "$2"/ie;
print;
}

this is the css:

.tlLinkSubQuarter {
width:24%;
float:left;
overflow:hidden;
font-size:12px;
}

When I run the filter, bbedit did its job it seems but nothing changes..

can a perl pro trace this simple code for me and or explain it?

cheers.bo

On Sat, May 7, 2011 at 10:24 AM, Robert Huttinger <[email protected]
wrote:


>
> while (<>){
>
>    s/([-a-z ]+:)\s+(.+)/sprintf("%-20s",$1) . "$2"/ie;
>    print;
> }
>

So the first group is all up to the colon, then the next group starts at
char 20? Ten the flags i & e

Thanks a ton!! I have had to convert lots of CSS and this makes it so much
cleaner.

Cheers.Bo

Squeezed out from my toothpaste tube



   - Bruce

_bruce__van_allen__santa_cruz_ca_

--
You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to