Compare two strings while ignoring 'A' or 'The' at the beginning
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.travis.yml
index.js
license
package.json
readme.md
test.js

readme.md

compare-ignoring-articles Build Status

Compare two strings while ignoring 'A' or 'The' at the beginning

Install

$ npm install --save compare-ignoring-articles

Usage

const compareIgnoringArticles = require('compare-ignoring-articles');

compareIgnoringArticles('The Title', 'Title');
//=> 0

API

compareIgnoringArticles(str1, str2[, caseSensitive])

str1

Type: string

The first string to use.

str2

Type: string

The second string to use.

caseSensitive

Type: bool Default: true

Whether or not the comparison should be case sensitive.

Return

  • Negative when the str1 occurs before str2
  • Positive when the str1 occurs after str2
  • Returns 0 if they are equivalent

Note that this is the same as String#localeCompare, which this library uses once articles have been stripped.

License

MIT © Matt Horn