# Regular Expressions: Using a variable as a RegExp

**URL:** <https://forum.kirupa.com/t/regular-expressions-using-a-variable-as-a-regexp/295420>\
**Category:** flash\
**Created:** [August 29, 2009, 9:10pm UTC](https://forum.kirupa.com/t/regular-expressions-using-a-variable-as-a-regexp/295420 "2009-08-29T21:10:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhat](https://avatars.discourse-cdn.com/v4/letter/m/96bed5/32.png) [@madhat](https://forum.kirupa.com/u/madhat)\
**Post date:** [August 29, 2009, 9:10pm UTC](https://forum.kirupa.com/t/regular-expressions-using-a-variable-as-a-regexp/295420/1 "2009-08-29T21:10:22Z")

</div>

Hi All,  
I am using RegExp to search for character sequences within strings. I was wondering if/what is the proper way to use a string stored in a variable as a regular expression. For example:

```auto

[LEFT][COLOR=#993300]var[/COLOR] someString:[COLOR=#993300]String[/COLOR] = [COLOR=#0000ff]"blah";[/COLOR]
[COLOR=#993300]var[/COLOR] expPattern:RegExp = [COLOR=#0000ff]"/"[/COLOR]+someString+[COLOR=#0000ff]"/"[/COLOR]; [COLOR=#f000f0]*//Waahhhh! I really want this to work!!!! *[/COLOR][/LEFT]

```

Any help greatly appreciated. Otherwise, I think I’ll have to use another string manipulation tool to search for the sequence. I think that RegExp might be the easiest solution. Hopefully my syntax is incorrect.  
Thanks,  
MadHat
