Skip to content

sp4ce/javascript-lcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published