5 Replies Latest reply on Jul 10, 2009 2:14 PM by softsafari

    Find multiple occurence of a dynamic string using RegExp?


      I need to find multiple instances ( there may only be one)  of a dynamic text. For instance


      var searchForThis:String = "hi";


      var regEx:RegExp = \b/searchForThis/\b


      The above does not actually compile and if  I remove the two \b it is actually searching for the word   searchForThis and not hi.


      1) How can I set up RegExp to search for a word not just a substring that is dynamic and will find multiple occurrences along with the start index of each occurrence?   So if I had the string   "hi there by there hi again. Where is the highway"   it would find two matches. It would not include highway since this hi is just a substring. I would be looking for words