l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
January 6: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2001 Dec 30 16:57

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] newbie regexp question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] newbie regexp question


  • Subject: Re: [vox-tech] newbie regexp question
  • From: Micah Cowan <micah@cowanboxMAPS.com>
  • Date: Thu, 28 Sep 2000 13:51:48 -0700
  • References: 39D3A735.F5C448BB@sagresdiscovery.com
  • References: 86zoksw961.fsf@123.211.6.64.reflexcom.com

On Thu, Sep 28, 2000 at 01:31:18PM -0700, Ricardo Anguiano wrote:
> 
> Eric Engelhard <ekengelhard@sagresdiscovery.com> writes:
> 
> > Hi all,
> > 
> > I am writing a perl script to process DNA sequences and want to use
> > regular expressions to mark a site at known landmarks (exact sequence
> > match) and cut the sequence both before AND after these landmarks. I
> > promise to whip out the regexp O'Reilly book tonight, but I need a
> > demo up in a couple hours. First correct answer scores a pint of hony
> > beer (12% alcohol).
> > 
> > -- Eric K. Engelhard
> 
> Will this work?  Keep the beer if it does.
> 
> #!/usr/bin/perl
> while (<>) {
> chomp;
> if (/(.*)(exactSequence)(.*)/) {
>     $beforematch = $1;
>     $match = $2;
>     $aftermatch = $3;
> }
> 
> -Ricardo

Or:

#!/usr/bin/perl
undef $/;       # slurp the file into a scalar
$contents = <>;
$contents =~ /$exactSequence/;
$beforeMatch = $`;
$match = $&;
$afterMatch = $';

- Micah


LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.