Adobe 12040118 Using Help - Page 186
If no match is found using the Regular Expression looking for a number string
![]() |
UPC - 718659361808
View all Adobe 12040118 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 186 highlights
Help Using Help Examples Back 186 Now we add a function to test whether a given file is part of a sequence. This uses Regular Expressions, which are a special type of JavaScript designed to reduce the number of steps required to evaluate a string. The first one tests for the presence of sequential numbers anywhere in the file name, followed by another making certain that the sequential files aren't of a type that can't be imported as a sequence (moving image files). We then check adjacent files to see if a sequence exists, stopping after we've evaluated ten files to save processing time. function testForSequence (files){ var searcher = new RegExp ("[0-9]+"); var movieFileSearcher = new RegExp ("(mov|avi|mpg)$", "i"); var parseResults = new Array; for (x = 0; (x < files.length) & x < 10; x++) { //test that we have a sequence, stop parsing after 10 files var movieFileResult = movieFileSearcher.exec(files[x].name); if (! movieFileResult) { var currentResult = searcher.exec(files[x].name); If no match is found using the Regular Expression looking for a number string, we get null and assume there is no image sequence. Otherwise, we want an array consisting of the matched string and its location within the file name. if (currentResult) { //we have a match - the string contains numbers //the match of those numbers is stored in the array[1] //take that number and save it into parseResults parseResults[parseResults.length] = currentResult[0]; } else { parseResults[parseResults.length] = null; } } else { parseResults[parseResults.length] = null; } } Now if all of the files just evaluated indicated that they are part of a numbered sequence, we assume that we have a sequence and return the first file of that sequence. Otherwise, we end this function. var result = null; for (i = 0; i < parseResults.length; ++i) { if (parseResults[i]) { if (! result) { result = files[i]; } } else { //case in which a file name did not contain a number result = null; break; } Using Help Back 186
![](/manual_guide/products/adobe-12040118-using-help-afc463d/186.png)