Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Grep a particular text

by ponni (Novice)
on Jul 09, 2019 at 10:30 UTC ( #11102593=perlquestion: print w/replies, xml ) Need Help??

ponni has asked for the wisdom of the Perl Monks concerning the following question:

Dear PerlMonks,
I am new to Perl, and i am learning to perl. Here a small grep process program required, in the entire document need to extract the query text and placed into the subsequent paragraphs.

\section{Funding\qr{The Funding statement in the Acknowledgment has been moved to Funding section. Please check and confirm if the edit is fine and amend if necessary.}}

I need to extract \qr{...text...} in all section and need to place in the below paragraph.
Kindly help genius!

Replies are listed 'Best First'.
Re: Grep a particular text
by haj (Chaplain) on Jul 09, 2019 at 11:49 UTC
    Maybe something like this:
    my $text = '\section{Funding\qr{The Funding statement in the Acknowled +gment has been moved to Funding section. Please check and confirm if +the edit is fine and amend if necessary.}}'; $text =~ s/(\\qr\{.*?\})\}/}\n\n$1/g; print "$text\n";
    The regular expression grabs the \qr followed by "simple" text in curly braces, and puts it after the curly brace of the \section. This prints:
    \section{Funding} \qr{The Funding statement in the Acknowledgment has been moved to Fund +ing section. Please check and confirm if the edit is fine and amend i +f necessary.}
Re: Grep a particular text
by choroba (Archbishop) on Jul 09, 2019 at 11:38 UTC
    Is the text always on a single line?

    How are paragraphs delimited?

    Can you show the expected output?

    It's not clear whether the text should be placed into the subsequent paragraphs or in the below paragraph.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Thanks for your reply. My expected output was in below:
      \section{Funding}
      The work was supported\qr{The Funding statement in the Acknowledgment has been moved to Funding section. Please check and confirm if the edit is fine and amend if necessary.} by the National Genetically Modified New Varieties of Major Projects of China (2016ZX08010004--004), the National Natural Science Foundation of China (Nos. 31771418, 31570261), and Key Project of Hubei Province~(2017AHB041).

      I have many sections with individual queries are present.
String manipulation in a document
by ponni (Novice) on Jul 10, 2019 at 05:32 UTC

    Dear PerlMonks

    I need to extract the query information starts with "\qr{...text..} and placed in the next paragraph for all section in a document. How to achieve using perl

    Here i listed some occurances:

    \section{Results\qr{text ... text}}

    Normal paragraph text here...

    \section{Funding\qr{text ... text}}

    Funding text here...

    Output required

    \section{Results}

    Normal paragraph\qr{Results section query text ... text} text here...

    \section{Funding}

    Funding text \qr{Funding query text bla bla bla}here...

      Welcome to Perl and the Monastery, ponni!

      AFAICT, this is simply additional information to your question from yesterday. In this case, please reply to the original thread instead of starting a new one. But please don't re-post this node either; I have considered it for moving into that thread.

      What have you tried? What documentation have you read?

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

        Dear sir, i am new to perl, and i need to cleanup my .tex file.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-03-29 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (168 votes). Check out past polls.

    Notices?