Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

regular expression

by cburger (Acolyte)
on Jan 26, 2011 at 00:27 UTC ( #884258=perlquestion: print w/ replies, xml ) Need Help??
cburger has asked for the wisdom of the Perl Monks concerning the following question:

hi I have a question:

I am trying to write a regular expression where I am matching every word/sign across new line characters, so I need an expression which combined .* and \n\s but all combinations I tried so far did not work. Help would be very appreciated.

$/=">"; while(<F>) { if ($_=~/\<word1\>(.*)\<word2\>/) { $g=$1; } close(F);

Replies are listed 'Best First'.
Re: regular expression
by jethro (Monsignor) on Jan 26, 2011 at 00:41 UTC

    You need the s modifier, i.e. /.../s, so that '.' in your regular expression also matches \n

      thanks jethro it works now!

Re: regular expression
by Anonymous Monk on Jan 26, 2011 at 00:41 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2016-06-30 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (395 votes). Check out past polls.