
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
exceptional-expressions
Advanced tools
An incredible way to build efficient, concise and human readable regular expressions.
An incredible way to build efficient, concise and human readable regular expressions.
Made with ❤️ by ohitslaurence
Using yarn:
$ yarn add exceptional-expressions
Using npm:
$ npm install exceptional-expressions
Using bower:
$ bower install exceptional-expressions
import { ExpBuilder, or, Constants, anythingBut } from 'exceptional-expressions;
const builder = new ExpBuilder('ig');
builder
.beginsWith(or(['hello', 'goodbye']))
.followedBy(Constants.whitespace)
.endsWith(anythingBut('world'));
builder.matchesString('Hello World'); // false
builder.matchesString('Goodbye Earth'); // true
builder.matchesString('hello world'); // false
builder.matchesString('helloearth'); // false
The exceptional expressions builder class exposes many methods for chaining expressions in various combinations. These methods, combined with the various utility functions provide extensive functionality such as named grouping, or and optional chaining, exclusions and many more.
// Optional chaining
import { ExpBuilder, or, Constants, Sequences } from 'exceptional-expressions;
const builder = new ExpBuilder('g');
builder
.beginsWith('(a)')
.orBeginsWith('(b)')
.followedBy(Constants.whitespace)
.followedBy(or([Constants.word, Sequences.numbers(3)]));
builder.matchesString('(a) Test'); // true
builder.matchesString('(b) word'); // true
builder.matchesString('(a)string'); // false
builder.matchesString('(a) 123'); // true
builder.getMatches('(a) first extra test string (b) second');
// ['(a) first']
builder.toRegex(); // /^(?:(?:\(a\))|(?:\(b\)))\s(?:(?:[A-Za-z']+\b)|(?:[\d]{3}))/g
Named groups allow you to group chunks of your expression and then extract that chunk by the name that you gave it. This functionality seeks to improve on the regex.exec(string)
method, which requires you to keep careful track on the ordering of your regex capture groups in order to determine which array index your group will be extracted into.
// Named groups
import { ExpBuilder, group, Constants } from 'exceptional-expressions;
const builder = new ExpBuilder('g');
builder
.contains(group([Constants.word, '.', Constants.word], 'username'))
.followedBy('@')
.followedBy(
group([
group(Constants.word, 'company'), '.', group(Constants.word, 'tld')
], 'domain')
);
builder.getCaptureGroups();
// ['username', 'domain', 'company', 'tld']
builder.matchesString('test.person@example.com');
// true
builder.getMatchesWithGroups('test.person@example.com, another.guy@test.io')
/* [{
match: 'test.person@example.com',
groups:
{
username: 'test.person',
domain: 'example.com',
company: 'example',
tld: 'com'
}
},
{
match: 'another.guy@test.io',
groups:
{
username: 'another.guy',
domain: 'test.io',
company: 'test',
tld: 'io'
}
}]
*/
builder.getMatchesByGroup('test.person@example.com, another.guy@test.io', 'company')
// ['example', 'test']
FAQs
An incredible way to build efficient, concise and human readable regular expressions.
We found that exceptional-expressions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.