# How to truncate ".jpg" of end of variable string

**URL:** <https://forum.kirupa.com/t/how-to-truncate-jpg-of-end-of-variable-string/7916>\
**Category:** flash\
**Created:** [November 10, 2002, 7:55am UTC](https://forum.kirupa.com/t/how-to-truncate-jpg-of-end-of-variable-string/7916 "2002-11-10T07:55:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![3dron](https://avatars.discourse-cdn.com/v4/letter/3/2acd7d/32.png) [@3dron](https://forum.kirupa.com/u/3dron)\
**Post date:** [November 10, 2002, 7:55am UTC](https://forum.kirupa.com/t/how-to-truncate-jpg-of-end-of-variable-string/7916/1 "2002-11-10T07:55:53Z")

</div>

I create a loadJPG function that auto matically creates an mc.

I want the mc to have the same name as the jpeg without the extension, how can I truncate the “.jpg” off?

jpg = test.jpg

I want mc to = test

Ron

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2002, 8:20am UTC](https://forum.kirupa.com/t/how-to-truncate-jpg-of-end-of-variable-string/7916/2 "2002-11-10T08:20:58Z")

</div>

This should work:

```php
normal = "h88.jpg";
modified = normal.substring(0, normal.lastIndexOf("."));
DynamicTextField.text = modified;

```

hope it helps! u just debug this code to suits u!

yours,  
–h88

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2002, 7:04pm UTC](https://forum.kirupa.com/t/how-to-truncate-jpg-of-end-of-variable-string/7916/3 "2002-11-10T19:04:10Z")

</div>

It seems that u didnt c my post, ill post that post to notify u 3dRON
