Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2006

    Nokia wrt RegExp engine

    Trying to implement a simple replace str in javascript on Nokia wrt

    trying to replace '+' in a string with ' '.

    var sStr = '1ft+ e';
    str= str.replace("\+",' ');

    Works in firefox but when trying on the device it returns an error saying
    SyntaxError: Invalid regular expression: nothing to repeat

    Can anyone tell me what is going wrong here?

    Something different about how the device handles reg-exp's than thenokia wrt viewer and firefox

    I'm not well versed in javascript aswell, as when this replace doesn;t fail in nokia wrt or firefox, it still does not replace the char in the string

    Cheers for any input, seems like a very mundane question that should have an easy answer

    var regex = new RegExp("[.+]", "g");
    str= str.replace(regex,' ');

    works in firefox & nokia wrt viewer in aptana, but not on device, same error as before
    Last edited by chops1; 2010-06-19 at 06:26. Reason: more info

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Rome, Italy

    Re: Nokia wrt RegExp engine

    Hi chops1,

    have you already tried with the forward slash syntax? Specifically, your first snippet could be rewritten as:

    var str = '1ft+ e';
    str= str.replace(/\+/, " ");
    Let me know if this works for you

    PS: just noticed that you have a typo in that snippet, since you use two different variable names, 'str' and 'sStr'

  3. #3
    Registered User
    Join Date
    Sep 2006

    Re: Nokia wrt RegExp engine

    Cheers thanks for the advice,

    I have been using
    var specials = new RegExp("[+]", "g");
    str= str.replace(specials , " ");

    and it seems to work now.

    It could have been throwing the error becasue the string i was trying to run the replace on was empty, cant be sure.

    Thanks for the alternative method

Similar Threads

  1. Nokia http client engine example problem?
    By giedi1 in forum Symbian
    Replies: 2
    Last Post: 2011-05-04, 12:58
  2. Replies: 0
    Last Post: 2009-12-08, 09:14
  3. Please somebody improve Forum Nokia Search Engine
    By arpit2agrawal in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 2
    Last Post: 2008-12-19, 04:56
  4. Replies: 0
    Last Post: 2008-01-11, 09:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts