Returns everything before the last period, if any. : indexOf lastIndexOf « String « Flash / Flex / ActionScript

Flash / Flex / ActionScript
1. Animation
2. Array
3. Class
4. Data Type
5. Development
6. Function
7. Graphics
8. Language
9. Network
10. Regular Expressions
11. Statement
12. String
13. TextField
14. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Flash / Flex / ActionScript » String » indexOf lastIndexOf 
Returns everything before the last period, if any.
 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        traceremoveExtension"document.jpg" ) );       // Displays: document
        traceremoveExtension"document" ) );           // Displays: document
        traceremoveExtension"document.1.jpg" ) );     // Displays: document.1
        traceextractExtension"document.jpg" ) );      // Displays: .jpg
        traceextractExtension"document" ) );          // Displays nothing
        traceextractExtension"document.1.jpg" ) );    // Displays: .jpg


    }
    private function removeExtensionfilename:String ):String {
      var extensionIndex:Number = filename.lastIndexOf'.' );
      if extensionIndex == -) {
        return filename;
      else {
        return filename.substr0, extensionIndex );
      
    }
    
    private function extractExtensionfilename:String ):String {
      var extensionIndex:Number = filename.lastIndexOf'.' );
      if extensionIndex == -) {
        return "";
      else {
        return filename.substrextensionIndex + 1, filename.length );
      
    }

  }
}

        
Related examples in the same category
1. Finding Substrings
2. Find all the occurrences of a substring.
3. Use indexOf and lastIndexOf to locate specific string
4. Use indexOf to check the existance of an substring
5. Searching for a Substring
6. Use offset index in indexOf method to search substring
7. Use indexOf( ) in a while statement to get the indices of every occurrence of a substring
8. Use lastIndexOf to search string
9. Use offset in lastIndexOf method
10. Is indexOf case sensitive
11. Use the lastIndexOf method to get the file extension name
12. Use indexOf in while loop to count the instance of a substring
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.