Thread Subject: regular expression

Subject: regular expression

From: Arthur Zheng

Date: 11 Jul, 2009 20:45:03

Message: 1 of 3

"lists" is a 1*316 char, the content of which is

lists =

aau_enzyme.list aau_pathway.list a.aurescens.pep
aau_genome.list aau_pfam.list a.aurescens.pos
aau_jcvi-cmr.list aau_prosite.list aau_tigr.list
aau_ko.list A.aurescens.ent aau_uniprot.list
aau_ncbi-geneid.list a.aurescens.genome aau_xrefall.list
aau_ncbi-gi.list a.aurescens.nuc

What pattern shall I use to find the file ending with ".genome" in the "lists" string?
In this case, the file that matches the pattern should be "a.aurescens.genome".
BTW the matlab function i am using is "regexpi". thanks.

Subject: regular expression

From: Rune Allnor

Date: 11 Jul, 2009 21:28:54

Message: 2 of 3

On 11 Jul, 22:45, "Arthur Zheng" <hzhe...@gatech.edu> wrote:
> "lists" is a 1*316 char, the content of which is
>
> lists =
>
> aau_enzyme.list       aau_pathway.list    a.aurescens.pep
> aau_genome.list       aau_pfam.list       a.aurescens.pos
> aau_jcvi-cmr.list     aau_prosite.list    aau_tigr.list
> aau_ko.list           A.aurescens.ent     aau_uniprot.list
> aau_ncbi-geneid.list  a.aurescens.genome  aau_xrefall.list
> aau_ncbi-gi.list      a.aurescens.nuc
>
> What pattern shall I use to find the file ending with ".genome" in the "lists" string?
> In this case, the file that matches the pattern should be "a.aurescens.genome".
> BTW the matlab function i am using is "regexpi". thanks.

rexp = '[^ ]*\.genome'; % [^ ]* = Any number of 'not space'
caharacters
                        % \.genome = '.genome'
[i1,i2]=regexp(lists,rexp);
filename = lists(i1:i2)

Rune

Subject: regular expression

From: Arthur Zheng

Date: 11 Jul, 2009 21:49:03

Message: 3 of 3

Rune Allnor <allnor@tele.ntnu.no> wrote in message <6f5f37a5-73bb-4d9f-9947-b791315e517f@f30g2000vbf.googlegroups.com>...
> On 11 Jul, 22:45, "Arthur Zheng" <hzhe...@gatech.edu> wrote:
> > "lists" is a 1*316 char, the content of which is
> >
> > lists =
> >
> > aau_enzyme.list ? ? ? aau_pathway.list ? ?a.aurescens.pep
> > aau_genome.list ? ? ? aau_pfam.list ? ? ? a.aurescens.pos
> > aau_jcvi-cmr.list ? ? aau_prosite.list ? ?aau_tigr.list
> > aau_ko.list ? ? ? ? ? A.aurescens.ent ? ? aau_uniprot.list
> > aau_ncbi-geneid.list ?a.aurescens.genome ?aau_xrefall.list
> > aau_ncbi-gi.list ? ? ?a.aurescens.nuc
> >
> > What pattern shall I use to find the file ending with ".genome" in the "lists" string?
> > In this case, the file that matches the pattern should be "a.aurescens.genome".
> > BTW the matlab function i am using is "regexpi". thanks.
>
> rexp = '[^ ]*\.genome'; % [^ ]* = Any number of 'not space'
> caharacters
> % \.genome = '.genome'
> [i1,i2]=regexp(lists,rexp);
> filename = lists(i1:i2)
>
> Rune

thanks Rune. It works.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
regular expression Sprinceana 12 Jul, 2009 03:54:55
regexp Sprinceana 12 Jul, 2009 03:54:55
regexpi regexp ... Arthur Zheng 11 Jul, 2009 16:49:04
rssFeed for this Thread

Contact us at files@mathworks.com