Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: grep for ending with double quotes

by davido (Archbishop)
on Jun 25, 2013 at 06:16 UTC ( #1040537=note: print w/ replies, xml ) Need Help??


in reply to Re^2: grep for ending with double quotes
in thread grep for ending with double quotes

Remember how in my first reply, removing the ^ eliminated the requirement that the match occur at the beginning of the string? Guess what. Putting it back will reinstate that requirement:

my @arr = grep /^"/, @arr_s;

One metacharacter at a time, one question at a time is a really inefficient way to learn about regular expressions. Please have a look at perlretut, perlrequick, and perlre. The first two of those documents will take a half hour to 45 minutes to get through, and then you'll be ready to save the day with regular expressions. ;)

Update: I can see I missed the part of your question that says words shouldn't end with ":

/^"[^"]$/

That would accept anything that starts with a ", but contains no " characters after that. Or...

/^"\p{Alpha}+$/

In the old days "\w" was marginally useful, but in a Unicode world, \p{Alpha} is probably more accurate. By the way, are you worried about words like "ain't" and "they're"?


Dave


Comment on Re^3: grep for ending with double quotes
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2015-07-06 15:28 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 (77 votes), past polls