Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Javascript-lcs

String comparison in Javascript. This Javascript library uses longest string subsequence algorithm to do string comparison.

Clone with git:

git clone git://github.com/sp4ce/javascript-lcs
cd javascript-lcs

Code sample:

<!-- Include the library in your html source -->
<script type="text/javascript" src="javascript-lcs.js"></script>

// Call the comparison and get the result matrix.
var result = lcs.compare(reference, input);

// Run throught the result and read the result
lcs.run(result, 0, 0, function(i, j) {
  if (result[i][j].status == lcs.DELETION) {
    console.log('Missing a caracter at index ' + j + '.');
  } else if (result[i][j].status == lcs.INSERTION) {
    console.log('Extra caracter at index ' + j + '.');
  }
});

Example:

Open example.html in your browser, enter a string in reference and input fields and press okbutton. It will display the matrix and highlight in red the path followed by the algorithm and display the detected errors.

Example

About

String comparison in Javascript

Resources

License

Releases

No releases published

Packages

No packages published