Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Regex Not Really Working

Hi
I'm implementing some search functionality using Regex, but it's not quite working. I want to search through a string for an instance of a search term.

Using RegEx(searchTerm, 'ig') produces the regular expression I'd expect, but the results don't always work.
i.e.

With James as the search term I get a positive result for jame but not for James or Jam

Any thoughts on this would be useful. Do I need to do something different to normal in my regex to get it to work in Titanium?

— asked May 25th 2010 by James Sugrue
  • iphone
0 Comments

3 Answers

  • Accepted Answer

    It appears they've fixed this bug in 1.3. If you're stuck on 1.2 like I am, case-sensitive matching should work.

    — answered May 25th 2010 by Damien Elmes
    permalink
    0 Comments
  • I'd suggest showing some code…… JavaScript's regular expression seems to be working just fine for me, and i'm using it a bit in the app i am working on

    — answered May 25th 2010 by Stephen Gilboy
    permalink
    0 Comments
  • Here's my code fragment:

       var re = new RegExp(searchTerm, 'ig');
       var str = allData[c].detail; 
       var result = re.test(str);
       Titanium.API.info(st + " vs Res: " + searchTerm  + " gives " +  result);
    

    Thanks for your help
    James

    — answered May 25th 2010 by James Sugrue
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.