# Photoshop - Javascript Split() Not Working

**URL:** https://forum.kirupa.com/t/photoshop-javascript-split-not-working/69507
**Category:** web dev
**Created:** [November 4, 2004, 10:10pm UTC](https://forum.kirupa.com/t/photoshop-javascript-split-not-working/69507 "2004-11-04T22:10:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![xgibbousx](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/xgibbousx/32/870_2.png) [@xgibbousx](https://forum.kirupa.com/u/xgibbousx)
#### Post date: [November 4, 2004, 10:10pm UTC](https://forum.kirupa.com/t/photoshop-javascript-split-not-working/69507/1 "2004-11-04T22:10:20Z")

</div>

Hi, I am writing a script for Photoshop CS in Javascript. Part of the script needs to take in a string variable (which is a filename in this case) and split it up into two components (the filename and its extension). For example, I need to take the string variable TEST.jpg and split it up into two array variables TEST and jpg. The code I am currently using to do this is as follows:

[size=2]var fileRefSplit = fileRef.split(".");  
var fileName = fileRefSplit[0];  
var extnName = fileRefSplit[1];

The problem is when I run the script in Photoshop CS I get an error stating “fileRef.split(”.") is not a function."

Is there an error with my code or does Photoshop CS scripting just not support the Javascript Split() function? Also, is there another way to split up a string variable in Javascript besides using the Split() function?

Any help is greatly appreciated.

[/size]
