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.

Fix #19, add test case#20

Open
nicolaiunrein wants to merge2 commits intoSimpleRegex:master
base:master
Choose a base branch
Loading
fromAuxControl:master
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
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 deletionslib/Builder.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -704,6 +704,7 @@ class Builder {
clone._modifiers = this._modifiers
clone._lastMethodType = this._lastMethodType
clone._group = this._group
clone._captureNames = Array.from(this._captureNames)

return clone
}
Expand Down
28 changes: 28 additions & 0 deletionstest/builder-test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,4 +178,32 @@ describe('Builder isMatching', () => {

assert.deepEqual(regex, /(?:foo)/)
})

it('Stores named captures', () => {
const regex_new = new SRL("capture (anything once or more) as first");
const testcase = 'hello world';

let matches_new = regex_new.getMatch(testcase)
assert.equal(matches_new["first"], 'hello world')

const regex_cached = new SRL("capture (anything once or more) as first");

let matches_cached = regex_cached.getMatch(testcase)
assert.equal(matches_cached["first"], 'hello world')

})
it('Stores named captures with implodeString', () => {
const query = "begin with literally 'hello '\ncapture (anything once or more) as first";
const regex_new = new SRL(query);
const testcase = 'hello world';

let matches_new = regex_new.getMatch(testcase)
assert.equal(matches_new["first"], 'world')

const regex_cached = new SRL(query);

let matches_cached = regex_cached.getMatch(testcase)
assert.equal(matches_cached["first"], 'world')

})
})

[8]ページ先頭

©2009-2025 Movatter.jp