Menu

Defining a custom splitter character

Help
lpanebr
2005-11-09
2013-04-11
  • lpanebr

    lpanebr - 2005-11-09

    I was going to post a question on how coul I achieve that but insted here's what I did.
    Extremely simple but makes it easier to choose what character should separate the sugested items... (I needed it to be ";")

    Hope it's of use...

    ADDED:
    splitter = ','; //define the custom splitter char

    CHANGED:

    function getUserInputToMatch(s) {
    ...
    fields = s.split(splitter);
    ...
    }

    function getUserInputBase() {
    ...
    if ((lastComma = s.lastIndexOf(splitter)) != -1) {
        a = a.replace(/^(.*\splitter[ \r\n\t\f\s]*).*$/i,'$1');
    ...
    }

    function runMatchingLogic(userInput, standalone) {
    ...
        if (siw) {
            siw.lastUserInput = userInput;
            siw.revisedCollection = tempCollection.join(splitter).split(splitter);
            collectionIndex[userInput] = tempCollection.join(splitter).split(splitter);
        }
        if (standalone || siw.buildIndex) {
            collectionIndex[uifc] = tempCollection.join(splitter).split(splitter);
            if (siw) siw.buildIndex = false;
        }
    }//runMatchingLogic

    function activateCurrentSmartInputMatch() {
    ...
            theString = (baseValue ? baseValue : "") + addedValue + splitter + " ";
    ...
    }

     
    • lpanebr

      lpanebr - 2005-11-09

      sorry..  this has a bug on the regular expressions.. I'm trying to fix it...

       
    • Dave Mahon

      Dave Mahon - 2006-01-31

      Could you use:

      var RegularExpression  =  new RegExp("^(.*"+splitter+"[ \r\n\t\f\s]*).*$","i");
      a = a.replace(RegularExpression,'$1');

      Granted, I haven't tested it, but it seems like it would work...

       

Log in to post a comment.

MongoDB Logo MongoDB