regex: remove file ext
From: picaza (icaza_at_earthlink.net)
Date: 10/29/04
- Next message: Tris Orendorff: "Re: Best references for buidling a webcrawler"
- Previous message: Rhino: "Deploying MIDlet via cable?"
- Next in thread: Carl Howells: "Re: regex: remove file ext"
- Reply: Carl Howells: "Re: regex: remove file ext"
- Reply: Alan Moore: "Re: regex: remove file ext"
- Reply: Oscar kind: "Re: regex: remove file ext"
- Reply: picaza: "Re: regex: remove file ext"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 29 Oct 2004 20:54:01 GMT
hi,
i am trying to lope off the extention of filenames as i read them w/ a
regex. seems like it should be easy but i cant get the regex to work.
i would like to use "\\.\\w$" or "\\.\\S$" but they dont work.
what does work is
"\\...$" or "\\.nc$"
but these dont offer the flexibility i want. the snippet of code follows
thanks,
peter.
+++++++++++++++
/ the regex is ".\w$" a dot followed by a word at the end of the str
Pattern fileExtRegEx = Pattern.compile("\\.\\w$");
Matcher FileExtMatcher;
while ((str = in.readLine()) != null)
{
FileExtMatcher = fileExtRegEx.matcher(str);
str = FileExtMatcher.replaceAll("");
allNames.add(str);
}
++++++++++++
- Next message: Tris Orendorff: "Re: Best references for buidling a webcrawler"
- Previous message: Rhino: "Deploying MIDlet via cable?"
- Next in thread: Carl Howells: "Re: regex: remove file ext"
- Reply: Carl Howells: "Re: regex: remove file ext"
- Reply: Alan Moore: "Re: regex: remove file ext"
- Reply: Oscar kind: "Re: regex: remove file ext"
- Reply: picaza: "Re: regex: remove file ext"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|