Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: regex at word boundary

by mikeraz (Friar)
on Dec 12, 2005 at 16:45 UTC ( [id://516052]=note: print w/replies, xml ) Need Help??


in reply to Re: regex at word boundary
in thread regex at word boundary

The code at that Re^5: regex at word boundary fails on overlapping palindromes, not that I'm aware of any that exist in the wild. Such that adding

nested testest detsen nested
i prefer pi ip referp
yeilds:

line 7:
(0) "nested testest detsen nested"
(7) "testest detsen nested"
(15) "detsen nested"
(22) "nested"

line 8:
(0) "i prefer pi ip referp"
(2) "prefer pi ip referp"
(9) "pi ip referp"
(12) "ip referp"
(15) "referp"
I also tested it on a handy text file of 79,569 lines and it ran much slower than the code I listed above, modified to just test on each line, not each paragraph.
sunorccws04 ~$ time ./mr_pal.pl trf > mr.out

real    1m2.161s
user    1m1.210s
sys     0m0.280s

sunorccws04 ~$ time ./qm_pal.pl trf > qm.out

real    2m53.492s
user    2m49.070s
sys     0m1.690s
trf is the output of a tcpdump session. Other data sets are sure to produce differing comparative speeds.

Be Appropriate && Follow Your Curiosity

Replies are listed 'Best First'.
Re^3: regex at word boundary
by QM (Parson) on Dec 12, 2005 at 18:16 UTC
    Are you comparing apples to apples? Does the other code find overlapping palindromes?

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      It does catch the overlapping. But I'm not comparing apples to apples because the RE in your code isn't working on my Solaris 5.6.1 code and it's generating many extra matches.

      Be Appropriate && Follow Your Curiosity

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://516052]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found