Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

I need help searching thesaurus for associated words, with least backtracking.

  •  09-10-2010, 8:42 AM

    I need help searching thesaurus for associated words, with least backtracking.

    I need to search a thesaurus such as 

    var thesaurus = "@,disappear,dematerialise,vanish,@,fat,massive,immense,@" 

    and return all synonyms (the words between @ seperated by commas) 

    I came up with:

    regex = ("@.*," +words[i]+ ".*?(?=@)");

    matchArray = thesaurus.match(regex);

    synonymLine = matchArray[0];

    synonymLine = synonymLine.slice(2, -1); //removes start @, and end ,

     

    essentially its matching the thesaurus for @.*,fat,.*@ problem is: it returns whole string from first @ to @ after word searched

    so I need to: make it just get the synonyms that apply to the word

     

    related javascript problem: Couldn't create a multi-line string so I made the thesaurus all one line.  Anyone know a workaround for both problems

View Complete Thread