views:

16

answers:

1

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 to regular expression.

Thanks.

A: 

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.
Vantomex