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.

JavaScript implementation of SRL.

License

NotificationsYou must be signed in to change notification settings

SimpleRegex/SRL-JavaScript

Repository files navigation

JavaScript implementation ofSimple Regex 🎉🎉🎉

npm versionBuild Statuscodecov

Because of the JavaScript regex engine, there is something different fromSimple Regex

  • NOT supportas to assign capture name.
  • NOT supportif already had/if not already had
  • NOfirst match and NOall lazy, since in JavaScriptlazy means non-greedy (matching the fewest possible characters).

Installation

npm install srl

Usage

Class SRL accepts a Simple Regex Language string as input, and return the builder for the query.

The builder can agenttest/exec method to the generated regex object. Or you can useget() to take the generated regex object.

constSRL=require('srl')constquery=newSRL('letter exactly 3 times')query.isMatching('aaa')// truequery.getMatch('aaa')// [ 'aaa', index: 0, input: 'aaa' ]query.digit().neverOrMore().mustEnd().get()// /[a-z]{3}[0-9]*$/g

Required Node 6.0+ for the ES6 support, Or you can useBabel to support Node below 6.0.

UsingWebpack andbabel-loader to pack it if want to use in browsers.

Additional

In SRL-JavaScript we applyg flag as default to follow theSimple Regex "standard", so we provide more API to use regex conveniently.

  • isMatching - Validate if the expression matches the given string.
  • getMatch - Get first match of the given string, like runregex.exec once.
  • getMatches - Get all matches of the given string, like a loop to runregex.exec.
  • removeModifier - Remove specific flag.

Development

First, clone repo and init submodule for test.

SRL-JavaScript depends onMocha andIstanbul to test code. You can use them like this:

npm installnpmtest# testnpm run coverage# Get coverage locally

How to write Rules, see:Test-Rules.

License

SRL-JavaScript is published under the MIT license. See LICENSE for more information.

About

JavaScript implementation of SRL.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp