How to replace a specidfic character in a phrase

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carcharoth
    New Member
    • May 2010
    • 2

    How to replace a specidfic character in a phrase

    I want to replace the 3 last characters of file, just before the dot in extension.

    I know there is a command to do it but i just can't fine it.

    I want it to go like this

    [code= Javascript]

    Var file = self.location.t oString();
    Var MyVar= ( 3 last characters before extension)


    If MyVar="_en" replace with "_gr"

    else replace with "_en"

    end if

    [/code]

    To give you an idea of what i'm trying to do,
    In the end i want it to be able to replace "SomePage_e n" with "Somepage_g r" and the opposite
    Excuse my ignorance in Java but i just started using it today.
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Sorry, are you trying to rename a file, or edit a file's contents?
    If the former, look at the File.renameTo function.

    Comment

    Working...