Re: Regex question

2002-10-05 Thread Lusercop

On Sat, Oct 05, 2002 at 02:15:34PM +0100, David Cantrell wrote:
> Ahhh, did someone annoy my little MBM?

Actually, no, for a change, it was just a swipe, after a conversation on
IRC. Chris knows I didn't actually mean it. ;-) If he doesn't, he really
should by now.

-- 
Lusercop.net - LARTing Lusers everywhere since 2002




Re: Regex question

2002-10-05 Thread David Cantrell

Ahhh, did someone annoy my little MBM?

--- Original message ---
> Other common quote characters include : | * and those five line
> paragraph quotes MS products create. Removing these would require some

Not to mention sodding supercite, not mentioning any names, Chris Ball.

-- 
David Cantrell | Benevolent Dictator | http://www.cantrell.org.uk/david

 Gehyrst þu, sælida, hwæt þis folc segeð? 
 Hi willað eow to gafole garas syllan, 
 ættrynne ord and ealde swurd, 
 þa heregeatu þe eow æt hilde ne deah. 
-- Brithnoth




Re: Regex question

2002-10-05 Thread Chris Ball

>> On 2002-10-05 09:30:15, Lusercop <`the.lusercop'@lusercop.net> said:

   > Not to mention sodding supercite, not mentioning any names, Chris
   > Ball.

Oi.  You could at least shout at Randal as well.  :-)

Anyway, my supercite is less annoying than most.  It doesn't do initials
for attribution any more, much less full first names.

I got forcibly made to stop using supercite at work once.  My boss sent
me an e-mail telling me that it was confusing; the e-mail was top-posted
and had punctuation errors, typos, and _awful_ contractions.

But then, I guess "I refuse to change my e-mail style for someone whose
.signature consists of 'cul8r'" wouldn't have gone down too well.

Sigh.

- Chris.
-- 
$a="printf.net";  Chris Ball | chris@void.$a | www.$a | finger: chris@$a





Re: Regex question

2002-10-05 Thread Lusercop

On Fri, Oct 04, 2002 at 04:21:44PM +0100, Paul Makepeace wrote:
> Other common quote characters include : | * and those five line
> paragraph quotes MS products create. Removing these would require some

Not to mention sodding supercite, not mentioning any names, Chris Ball.

-- 
Lusercop.net - LARTing Lusers everywhere since 2002




Re: Regex question

2002-10-04 Thread Paul Makepeace

On Fri, Oct 04, 2002 at 04:01:05PM +0100, Nick Cleaton wrote:
> I would use something like:
> 
>s#^[> ]+##mg;

FWIW, you might like to also wipe it through
Text::Autoformat::autoformat({all => 1})

Other common quote characters include : | * and those five line
paragraph quotes MS products create. Removing these would require some
messy logic or slurping your message whole (local $/;) into a string and
using a regex like:

s/^-+Original Message-+\nFrom: .*?\nSent: .*?\nTo: .*?\nSubject: .*?//mi



Paul

-- 
Paul Makepeace ... http://paulm.com/

"If cheese were less stinky, then I wouldn't complain."
   -- http://paulm.com/toys/surrealism/




Re: Regex question

2002-10-04 Thread nemesis

nemesis wrote:
> foreach my $line (@body) {
> $_ = $line;
> s/^(?:>|\s)*(.*)$/$1/g;
> print;
> }

Thanks for the suggested improvements.  It would have helped if @body wasn't 1 
element in size and that element contained the whole of the text :-)  Oh, and 
thanks for the phone support Dean.

Will





Re: Regex question

2002-10-04 Thread Dan Brook

> foreach my $line (@body) {
>   $_ = $line;
>   s/^(?:>|\s)*(.*)$/$1/g;
>   print;
> }
> 
> Any ideas what I am doing wrong here[3]

Works from here. Also you'll probably want to localise $_ and forget about 
re-appending the rest of the message e.g

s{ ^ (?: \s* >? \s* )* }()x

Which just strips off the offending characters.

Dan->nick() eq 'broquaint'




Re: Regex question

2002-10-04 Thread Roger Burton West

On Fri, Oct 04, 2002 at 03:59:10PM +0100, nemesis wrote:
>
>Hi all,
>
>I have a bunch of jokes that people have forwarded me over the years[1] and 
>they all have really bad formatting [2].  I am lazy and want to do as much 
>formatting of the jokes as I can automatically.  I have tried this piece of 
>code to get rid of any '>' or whitespace charachters before the 'beginning' 
>of each line of the text, but it just returns the same text as before:
>
>foreach my $line (@body) {
>   $_ = $line;
>   s/^(?:>|\s)*(.*)$/$1/g;
>   print;
>}
>
>Any ideas what I am doing wrong here[3]

This is rather more complex than it needs to be. Why not:

foreach (@body) { # it goes into $_ automatically
  s/^(>\s*)+//;
  print;
}

? (It works on your example.) Or even s/^[>\s]+//; (as Nick's pointed
out while I was writing this)?

The short answer is that it's not your regex that's wrong, it's messing
about with $_.

Roger




Re: Regex question

2002-10-04 Thread Nick Cleaton

On Fri, Oct 04, 2002 at 03:59:10PM +0100, nemesis wrote:
> 
> Hi all,
> 
> I have a bunch of jokes that people have forwarded me over the years[1] and they 
> all have really bad formatting [2].  I am lazy and want to do as much formatting 
> of the jokes as I can automatically.  I have tried this piece of code to get rid 
> of any '>' or whitespace charachters before the 'beginning' of each line of the 
> text, but it just returns the same text as before:
> 
> foreach my $line (@body) {
>   $_ = $line;
>   s/^(?:>|\s)*(.*)$/$1/g;
>   print;
> }

I would use something like:

   s#^[> ]+##mg;

--
Nick