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

Re: regex for removing quoted text

by atcroft (Monsignor)
on Mar 10, 2011 at 05:02 UTC ( #892345=note: print w/ replies, xml ) Need Help??


in reply to regex for removing quoted text

You want to look at the /s switch on the s/// operator. For instance, with the following code (in a one-liner with -l):

my $str = q{this is "a test} . qq{\n} . q{this is "only a "poor "test}; print $str; print qq{=====}; $str =~ s/"[^"]+"//gs; print $str;
I get the following result, which is similar to what you indicated you needed:
this is "a test this is "only a "poor "test ===== this is only a test

Hope that helps.

Update: 2011-03-09

I cannot help but second roboticus's references and suggestions. There is much useful information (and I now have another module to take a look at when I have "spare" time available again). :)

Update: 2011-03-09

It appears as if the module in question may be YAPE::Regex::Explain (as I found when I tried installing it to play with it myself).


Comment on Re: regex for removing quoted text
Select or Download Code
Replies are listed 'Best First'.
Re^2: regex for removing quoted text
by jwkrahn (Monsignor) on Mar 10, 2011 at 05:12 UTC

    You want to look at the /s switch on the s/// operator.

    $str =~ s/"[^"]+"//gs;

    The  /s option has no effect in the expression /"[^"]+"/, it is superfluous.

      Technically, but it still signals the authors intentions

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2015-07-08 05:02 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 (94 votes), past polls