8

How do I determine the file or regular channel? AS3

 3 years ago
source link: https://www.codesd.com/item/how-do-i-determine-the-file-or-regular-channel-as3.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How do I determine the file or regular channel? AS3

advertisements

I load strings from a mxl. Some of the strings are file paths and some of them are just normal strings. How I can to determine who is a file and who is a regular string?

Thanks


You can use a regular expression check on each string. This page explains usage and some examples of RegExp syntax. What your regular expression includes depends on what your file locations look like, but one thing you can look for is the file type suffix.

And I just found this tool for constructing and testing regular expressions.

The following regular expression would match any word (substring with no whitespace) ending with a file extension, such as .pdf or .mp3. But it will also recognize .com, .org, etc, so hopefully your strings don't contain website urls.

var str:String = inputString; // Each string you want to test.
var regEx:RegExp = /\.[a-zA-Z0-9]+\b/; // Note that no quotes are needed.
var matches:Boolean = regEx.test(str); // True for match, false for no match.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK