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

Re: regex at word boundary

by QM (Parson)
on Dec 10, 2005 at 15:48 UTC ( [id://515730]=note: print w/replies, xml ) Need Help??


in reply to regex at word boundary

Is the code at Re^5: regex at word boundary useful? I thought you might compare it with your filter version, and see what falls out. Also, it could be made to search across newlines, but at considerable slowdown if not done carefully.

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

Replies are listed 'Best First'.
Re^2: regex at word boundary
by mikeraz (Friar) on Dec 12, 2005 at 16:45 UTC

    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
      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://515730]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found