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

Re: Help with Double Double Quotes regular expression

by MonkE (Hermit)
on Apr 02, 2007 at 02:57 UTC ( [id://607744]=note: print w/replies, xml ) Need Help??


in reply to Help with Double Double Quotes regular expression

Why not just change the input string with s/""/"/g and the like. Then you can extract text between single quotes. Below you can see my attempt to extract the quoted data (tested).
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; # remove the pesky quotes at the beginning and end s/^"//; s/"$//; # change all doubled quotes into just singles s/""/"/g; print $_ . "\n"; } __DATA__ "" "a""""" "a""b""c""d""f" "This is a ""test""" "Here we have """"a nested set of double-quoted quotes"" or whatever." +"" "Harvey ""the Screwdriver"" Ledbetter"
Output:
a"" a"b"c"d"f" This is a "test" Here we have ""a nested set of double-quoted quotes" or whatever." Harvey "the Screwdriver" Ledbetter

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-26 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found