开发者

Actionscript: Regular expression for file type checking

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 number 1.
  • $ Assert position at the end of a line.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜