Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Pattern Matching on Case

Reply
Thread Tools

Pattern Matching on Case

 
 
Aaron Baugher
Guest
Posts: n/a
 
      02-20-2006
"Matt Garrish" <(E-Mail Removed)> writes:

> But then consider:


> <td>I like to</td><td>Format everything</td><td>Inside
> cells</td><td>On one line</td>


> Never underestimate a bad html parsing job... : )


Yep. When I really want to get the visible text of a page without the
html, `lynx -dump $url` comes in handy.


--
Aaron -- http://www.velocityreviews.com/forums/(E-Mail Removed)
http://360.yahoo.com/aaron_baugher
 
Reply With Quote
 
 
 
 
DANIEL BURCH
Guest
Posts: n/a
 
      02-20-2006
I think it was like:

<h1>This is a header</h1>This is some text.
"Samwyse" <(E-Mail Removed)> wrote in message newshcKf.34787$(E-Mail Removed). net...
DANIEL BURCH wrote:
> I have a file that apparently had html tags stripped out of it, or
> something, but no space characters added to replace the tags so it ended up
> with a lot of words run together like "ExplosionThis".


This is a bit off-topic, and definitely not related to Perl, but your
file didn't have HTML tags stripped from it. When stripping HTML tags,
you aren't supposed to replace them with whitespace. For example,
consider the following HTML, which italicizes some of the alphabet:

a<i>bcd</i>e<i>fgh</i>i<i>jklmn</i>o<i>pqrst</i>u<i>vwx</i>y<i>z</i>

Introducing spaces for the tags would mess everything up.
 
Reply With Quote
 
 
 
 
DANIEL BURCH
Guest
Posts: n/a
 
      02-20-2006

>That's why the OP will probably learn the hard way that regexes are more
>trouble than they're worth in this kind of situation, and that it's easier
>to go back to the source and start over. A spellchecker might prove more
>useful if that's not possible...


>Matt


Hey - It was about 9000 lines of data in text format. Kind of big to go
through with a spell checker. What Balls sent in his first post worked just
how I wanted it to. I had to add a few lines to it with more variables like
cases of ".Cap" and "!Cap" , but it fixed the file in about 30 seconds.

Thanks to the group for the posts.

Dan


 
Reply With Quote
 
DANIEL BURCH
Guest
Posts: n/a
 
      02-20-2006
>use strict; use warnings;

>my $string = 'Hello theRe danielBurch howAreYou?';
>$string =~ s/([a-z])([A-Z])/$1\ $2/g; # i escape the space b/c in Perl
>6 /x will be default
>print $string, "\n";


What Balls sent in his post worked just how I wanted it to. I had to add a
few lines to it with more variables like cases of ".Cap" and "!Cap" , but
it fixed the file.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to replace all strings matching a pattern with correspondinglower case strings ? anonym Java 1 01-15-2009 07:29 PM
Help with Pattern matching. Matching multiple lines from while reading from a file. Bobby Chamness Perl Misc 2 05-03-2007 06:02 PM
Pattern matching : not matching problem Marc Bissonnette Perl Misc 9 01-13-2004 05:52 PM
Pattern matching help! grep emails from file! danpres2k Perl 3 08-25-2003 02:47 PM
A newbie question on pattern matching DelphiDude Perl 3 07-26-2003 12:54 PM



Advertisments