
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
string-patternizer
Advanced tools
Inspired by (but not copied from) format-string-by-pattern. Converts any string to match a given pattern. Currently supports letters (case-sensitive or -insensitive), digits, symbols, "any character" and specific/required characters.
yarn add string-patternizer
npm i string-patternizer
pnpm add string-patternizer
Returns a string based on source, formatted according to pattern.
Note that this is not a validation tool: it will only convert strings according to the pattern provided, but not otherwise check for their content. In other words, no function is provided to e.g. limit an IP address string to numbers smaller than 256.
pattern: string
Describes how the input should be formatted.
Characters with special meaning:
d = any digita = any lowercase letterA = any uppercase letter_ = any letter* = any "other" (not digit or letter) character. = any character+ = repeat previous character type 0-infinite times\ = start of escape sequenceAny other character will be interpreted as "required", i.e. will automatically be copied as-is into the result string,
even if not present in the source string. The special characters above need to be escaped with a \ to be used as
"required".
Note: as JavaScript interprets a single backslash in string literals as an escape sign, you have to escape the backslash in string literals:
✅ patternize('aa\\.dd', 'ab.12')
❌ patternize('aa\.dd', 'ab.12')
source: string
The input value to be formatted.
import patternize from 'string-patternizer'
// US phone number (including country code)
patternize('\\+1 (ddd) ddd dddd', '5551234567');
// '+1 (555) 123 4567'
// Full name
patternize('Aa+ Aa+', 'firstname lastname');
// 'Firstname Lastname'
// IP address (format only, no validation i.e. numbers over 255 are possible)
patternize('ddd\\.ddd\\.ddd\\.ddd', '111222333444');
// '111.222.333.444'
// Currency
patternize('d+\\.dd€', '1234');
// '12.34€'
FAQs
Convert strings to match a pattern
We found that string-patternizer 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.