-
Notifications
You must be signed in to change notification settings - Fork 0
/
e-prime.js
46 lines (43 loc) · 845 Bytes
/
e-prime.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var toBe = [
'am',
'are',
'aren\'t',
'be',
'been',
'being',
'he\'s',
'here\'s',
'here\'s',
'how\'s',
'i\'m',
'is',
'isn\'t',
'it\'s',
'she\'s',
'that\'s',
'there\'s',
'they\'re',
'was',
'wasn\'t',
'we\'re',
'were',
'weren\'t',
'what\'s',
'where\'s',
'who\'s',
'you\'re'
];
var re = new RegExp('\\b(' + toBe.join('|') + ')\\b', 'gi');
module.exports = function (text) {
var suggestions = [];
if (!text || text.length === 0) return suggestions;
text = text.replace(/[\u2018\u2019]/g, "'"); // convert smart quotes
while (match = re.exec(text)) {
var be = match[0].toLowerCase();
suggestions.push({
index: match.index,
offset: be.length
});
}
return suggestions;
};