# Use a var in a Reg Exp? Use expression in .split(var).join(var)?

**URL:** <https://forum.kirupa.com/t/use-a-var-in-a-reg-exp-use-expression-in-split-var-join-var/310326>\
**Category:** flash\
**Created:** [June 7, 2010, 7:28pm UTC](https://forum.kirupa.com/t/use-a-var-in-a-reg-exp-use-expression-in-split-var-join-var/310326 "2010-06-07T19:28:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WinterWulf](https://avatars.discourse-cdn.com/v4/letter/w/8c91f0/32.png) [@WinterWulf](https://forum.kirupa.com/u/WinterWulf)\
**Post date:** [June 7, 2010, 7:28pm UTC](https://forum.kirupa.com/t/use-a-var-in-a-reg-exp-use-expression-in-split-var-join-var/310326/1 "2010-06-07T19:28:41Z")

</div>

Hello everyone - this is my very first post here, so I’ll try to keep it short and sweet:

I made this line of code:

```auto
Imput.text = Imput.text.split(LastSelectedCommand).join(CommandList.selectedItem.data);

```

However, I need it to search only once and at the very beginning of Imput.text. Using ^ in a regular expression should work, however, I have not been able to figure out how to use a variable’s value in a reg exp.

Any help will be greatly appreciated, thank you.
