Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: About regular expressions

by eye (Chaplain)
on Mar 31, 2009 at 06:18 UTC ( #754333=note: print w/ replies, xml ) Need Help??


in reply to About regular expressions

First, I'm assuming you don't want the terminal periods to be matched. You want to match:

St.John's high school
not:
St.John's high school.

I want to be cautious in answering this because the specification is just a series of examples. It's very possible that I do not actually understand the pattern you are trying to match. That said, I don't see a way to materially improve the performance of your regex. I can say with certainty that a poorly defined regex can adversely affect the performance of a program. Sadly, I do not know of a way to validate the efficiency of a regex.

The only vaguely useful suggestion I can offer is to use [a-z] in a case insensitive match instead of [a-zA-Z]. That makes it slightly easier to read, but has no affect on how the regex would perform.


Comment on Re: About regular expressions
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2015-07-05 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls