Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: regex pattern match problem

by newbio (Beadle)
on Aug 05, 2009 at 20:49 UTC ( #786222=note: print w/ replies, xml ) Need Help??


in reply to Re: regex pattern match problem
in thread regex pattern match problem

Yes, Polyglot, that's what I want. Could you please elaborate on your suggestion. How do I perform the non-global substitutions for their corresponding positions? It is possible that exactly the same pattern may get repeated in a sentence, so their positions need to be taken into account, possibly using substr function. Still, I cannot figure out how that works. I tried to do something like this but it does not work.

$string=$line="Input sentence"; if ($line =~ /\*\*([^\*]+)\*\*\s(kinase|isoform|protein|peptide|li +gand)\s\$\$([^\$]+)\$\$\s[\(\,]\s\*\*([^\*]+)\*\*\s[\)\,]/) { print "yes"; while ($line =~ /(\*\*([^\*]+)\*\*\s(kinase|isoform|protein|pe +ptide|ligand)\s\$\$([^\$]+)\$\$\s[\(\,]\s\*\*([^\*]+)\*\*\s[\)\,])/g) + { $pattern=$1; $string =~ s/(\*\*([^\*]+)\*\*\s(kinase|isoform|protein|pe +ptide|ligand)\s\$\$([^\$]+)\$\$\s[\(\,]\s\*\*([^\*]+)\*\*\s[\)\,])/pq +rstuv/; $string =~ s/\*\*//g; $string =~ s/\$\$//g; $string =~ s/p +qrstuv/$pattern/; print WF "$string\n"; $string=$line; } }


Comment on Re^2: regex pattern match problem
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (15)
As of 2014-09-30 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (376 votes), past polls