Re: reading pre-extension file
| From: | Ernest E Vogelsinger | Date: | Thu, 12 Dec 2002 09:52:35 +0000 |
| Subject: | Re: reading pre-extension file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127974@lists.php.net to get a copy of this message | ||
At 18:40 11.12.2002, Luca spoke out and said:
--------------------[snip]--------------------
>How to read "pre-extension" of file with regular expression?
>Example: name.preextension.doc
>
>I need to read "preextension"
--------------------[snip]--------------------
Assuming that "preextension" is _always_ preceded by at least one dot, and
_always_ followed by exactly one dot, this RE should work (untested):
/\.([^.]*)\.[^\.]*$/
read from right to left for better understanding:
line end
anything before without a dot ('ext')
a dot before
anything without a dot before (grouped, 'preext')
starting with a dot
The group will contain the preextension.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/