Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Add carriageReturn to simple mapper#12

Closed
corsonknowles wants to merge27 commits intoSimpleRegex:masterfromcorsonknowles:master
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
27 commits
Select commitHold shift + click to select a range
56be421
Comment in character classes to be added
corsonknowlesAug 9, 2017
a414232
Add carriage return placeholder comment
corsonknowlesAug 9, 2017
b61969e
Add helper methods and builder hashes for additonal RegEx character c…
corsonknowlesAug 9, 2017
b176e2d
Add all new character classes, clean up comments
corsonknowlesAug 9, 2017
bf6416b
Remove A and z character classes which are not supperted in JavaScrip…
corsonknowlesAug 10, 2017
1c96ab3
Modify test rules
corsonknowlesAug 10, 2017
cd5d7d4
Gitignore package lock and remove test package
corsonknowlesAug 11, 2017
d34d499
Remove nested git file
corsonknowlesAug 11, 2017
6903aa7
Move rules back into place
corsonknowlesAug 11, 2017
ba5d26d
Remove git submodule
corsonknowlesAug 11, 2017
af12154
change file encoding of new test rules
corsonknowlesAug 11, 2017
94127f2
Amend rules files for word and no word
corsonknowlesAug 11, 2017
1ceae8c
Change allowed type of word boundaries
corsonknowlesAug 11, 2017
580d3cb
Add mapper functions for word and nonword boundaries
corsonknowlesAug 11, 2017
b2e10f0
Fix all new test rules, verify working
corsonknowlesAug 11, 2017
36f440f
Hard delete package-lock
corsonknowlesAug 11, 2017
95e0e87
Restore .gitmodules for test
corsonknowlesAug 12, 2017
bf41185
Update package.json
corsonknowlesAug 12, 2017
e442703
Move rules files to submodule repo
corsonknowlesAug 12, 2017
3c81766
remove duplicate rules files
corsonknowlesAug 12, 2017
8369c3e
Remove only rules file duplicates
corsonknowlesAug 12, 2017
2a6bc57
Reactivate submodule
corsonknowlesAug 12, 2017
042dd46
Add vertical tab as supported JavaScript regex character, and remove …
corsonknowlesAug 12, 2017
637cdf8
Add support for text input of backslash
corsonknowlesAug 13, 2017
a4185a3
Amend vertical tab in mbuilder and methodMatch
corsonknowlesAug 13, 2017
9e3e75a
Add carriageReturn to simple mapper
corsonknowlesAug 14, 2017
b906f13
Double escape backslashtranslation
corsonknowlesAug 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
node_modules
coverage
.vscode
package-lock.json
76 changes: 74 additions & 2 deletionslib/Builder.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,16 +39,31 @@ const simpleMapper = {
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'backslash': {
'add': '\\\\',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'tab': {
'add': '\\t',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'verticalTab': {
'add': '\\v',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'newLine': {
'add': '\\n',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'carriageReturn': {
'add': '\\r',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'whitespace': {
'add': '\\s',
'type': METHOD_TYPE_CHARACTER,
Expand All@@ -68,7 +83,18 @@ const simpleMapper = {
'add': '\\W',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPES_ALLOWED_FOR_CHARACTERS
},
'word': {
'add': '\\b',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPE_BEGIN
},
'nonWord': {
'add': '\\B',
'type': METHOD_TYPE_CHARACTER,
'allowed': METHOD_TYPE_BEGIN
}

}

class Builder {
Expand DownExpand Up@@ -140,6 +166,21 @@ class Builder {
return this.add(`[${result}]`)
}

/**
* Literally match a character that is not one of these characters.
*
* @param {string} chars
* @return {Builder}
*/
noneOf(chars) {
this._validateAndAddMethodType(METHOD_TYPE_CHARACTER, METHOD_TYPES_ALLOWED_FOR_CHARACTERS)

let result = chars.split('').map((character) => this.escape(character)).join('')
result = result.replace('-', '\\-').replace(']', '\\]')

return this.add(`[^${result}]`)
}

/**
* Literally match all of these characters in that order.
*
Expand All@@ -166,6 +207,17 @@ class Builder {
return this.add(`[${min}-${max}]`)
}

/**
* Match any non-digit character (in given span). Default will be any character not between 0 and 9.
*
* @return {Builder}
*/
noDigit() {
this._validateAndAddMethodType(METHOD_TYPE_CHARACTER, METHOD_TYPES_ALLOWED_FOR_CHARACTERS)

return this.add(`[^0-9]`)
}

/**
* Match any uppercase letter (between A to Z).
*
Expand DownExpand Up@@ -194,10 +246,10 @@ class Builder {
/**********************************************************/

/**
* Match any of thesecondition.
* Match any of theseconditions.
*
* @param {Closure|Builder|string} conditions Anonymous function with its Builder as first parameter.
* @return {Builer}
* @return {Builder}
*/
anyOf(conditions) {
this._validateAndAddMethodType(METHOD_TYPE_GROUP, METHOD_TYPES_ALLOWED_FOR_CHARACTERS)
Expand DownExpand Up@@ -423,14 +475,26 @@ class Builder {
return this._addFromMapper('any')
}

backslash() {
return this._addFromMapper('backslash')
}

tab() {
return this._addFromMapper('tab')
}

verticalTab() {
return this._addFromMapper('verticalTab')
}

newLine() {
return this._addFromMapper('newLine')
}

carriageReturn() {
return this._addFromMapper('carriageReturn')
}

whitespace() {
return this._addFromMapper('whitespace')
}
Expand All@@ -447,6 +511,14 @@ class Builder {
return this._addFromMapper('noCharacter')
}

word() {
return this._addFromMapper('word')
}

nonWord() {
return this._addFromMapper('nonWord')
}

/**********************************************************/
/* INTERNAL METHODS */
/**********************************************************/
Expand Down
14 changes: 13 additions & 1 deletionlib/Language/Helpers/methodMatch.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,29 +13,41 @@ const SyntaxException = require('../../Exceptions/Syntax')
// Unimplemented: all lazy, single line, unicode, first match
const mapper = {
'any character': { 'class': SimpleMethod, 'method': 'anyCharacter' },
'backslash': { 'class': SimpleMethod, 'method': 'backslash' },
'no character': { 'class': SimpleMethod, 'method': 'noCharacter' },
'multi line': { 'class': SimpleMethod, 'method': 'multiLine' },
'case insensitive': { 'class': SimpleMethod, 'method': 'caseInsensitive' },
'starts with': { 'class': SimpleMethod, 'method': 'startsWith' },
'start with': { 'class': SimpleMethod, 'method': 'startsWith' },
'begin with': { 'class': SimpleMethod, 'method': 'startsWith' },
'begins with': { 'class': SimpleMethod, 'method': 'startsWith' },
'must end': { 'class': SimpleMethod, 'method': 'mustEnd' },
'once or more': { 'class': SimpleMethod, 'method': 'onceOrMore' },
'never or more': { 'class': SimpleMethod, 'method': 'neverOrMore' },
'new line': { 'class': SimpleMethod, 'method': 'newLine' },
'whitespace': { 'class': SimpleMethod, 'method': 'whitespace' },
'no whitespace': { 'class': SimpleMethod, 'method': 'noWhitespace' },
'anything': { 'class': SimpleMethod, 'method': 'any' },
'tab': { 'class': SimpleMethod, 'method': 'atb' },
'tab': { 'class': SimpleMethod, 'method': 'tab' },
'vertical tab': { 'class': SimpleMethod, 'method': 'verticalTab' },
'digit': { 'class': SimpleMethod, 'method': 'digit' },
'no digit': { 'class': SimpleMethod, 'method': 'noDigit' },
'nondigit': { 'class': SimpleMethod, 'method': 'noDigit' },
'number': { 'class': SimpleMethod, 'method': 'digit' },
'letter': { 'class': SimpleMethod, 'method': 'letter' },
'uppercase': { 'class': SimpleMethod, 'method': 'uppercaseLetter' },
'once': { 'class': SimpleMethod, 'method': 'once' },
'twice': { 'class': SimpleMethod, 'method': 'twice' },
'word': { 'class': SimpleMethod, 'method': 'word' },
'no word': { 'class': SimpleMethod, 'method': 'nonWord' },
'nonword': { 'class': SimpleMethod, 'method': 'nonWord' },
'carriage return': { 'class': SimpleMethod, 'method': 'carriageReturn' },
'carriagereturn': { 'class': SimpleMethod, 'method': 'carriageReturn' },

'literally': { 'class': DefaultMethod, 'method': 'literally' },
'either of': { 'class': DefaultMethod, 'method': 'anyOf' },
'any of': { 'class': DefaultMethod, 'method': 'anyOf' },
'none of': { 'class': DefaultMethod, 'method': 'noneOf' },
'if followed by': { 'class': DefaultMethod, 'method': 'ifFollowedBy' },
'if not followed by': { 'class': DefaultMethod, 'method': 'ifNotFollowedBy' },
'optional': { 'class': DefaultMethod, 'method': 'optional' },
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp