I want to check the file extension from the string using regular expression in action script.
By googling, I find this, but I'm week t开发者_开发知识库o regular expression.
Thanks.
This regex is more reliable than the given example:
^[^\\?\/%*:|"><]+\.([^\\?\/%*:|"><]*)$
You can refer to the file extension as $1
if you refer to it in replacement part.
You can refer to the file extension as \1
if you refer to it in search part.
Explanation
^
Assert position at the beginning of a line.[^\\?\/%*:|"><]+\.
Matches any character except\
,?
,/
,%
,*
,:
,|
,"
,>
,<
, at least one character, until the last.
character.([^\\?\/%*:|"><]*)
Matches any character except\
,?
,/
,%
,*
,:
,|
,"
,>
,<
, as many as possible or none, and capture the bracketed part as group number1
.$
Assert position at the end of a line.
精彩评论