
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
xml-char-classes
Advanced tools
Regular expressions for matching against the XML Character Classes
The xml-char-classes npm package provides regular expressions for matching XML character classes. It helps in validating and working with XML data by ensuring that characters conform to XML specifications.
Match XML Name Start Characters
This feature provides a regular expression to match valid XML name start characters. XML names must start with a letter or underscore, and this regex helps ensure that.
const xmlCharClasses = require('xml-char-classes');
const regex = new RegExp(`^[${xmlCharClasses.nameStartChar.source}]`);
console.log(regex.test('A')); // true
console.log(regex.test('1')); // false
Match XML Name Characters
This feature provides a regular expression to match valid XML name characters. XML names can include letters, digits, hyphens, underscores, and periods, and this regex helps ensure that.
const xmlCharClasses = require('xml-char-classes');
const regex = new RegExp(`^[${xmlCharClasses.nameChar.source}]+$`);
console.log(regex.test('A1-._')); // true
console.log(regex.test('A1-._ ')); // false
Match XML Char
This feature provides a regular expression to match valid XML characters. It ensures that the characters conform to the XML specification for valid characters.
const xmlCharClasses = require('xml-char-classes');
const regex = new RegExp(`^[${xmlCharClasses.char.source}]+$`);
console.log(regex.test('A1-._ ')); // true
console.log(regex.test('\u0000')); // false
The xml2js package is used for parsing XML to JavaScript objects and vice versa. While it does not focus on character classes, it provides comprehensive XML parsing and building functionalities.
The fast-xml-parser package is a fast and lightweight XML parser. It provides similar XML parsing capabilities but does not specifically focus on character classes like xml-char-classes.
The sax package is a streaming XML parser. It provides low-level parsing capabilities and can be used to validate XML data, but it does not specifically provide regular expressions for XML character classes.
Regular expressions for matching against the XML Character Classes
$ npm install xml-char-classes
import xmlCharacterClasses from 'xml-char-classes';
console.log(xmlCharacterClasses.digit);
//=> /[0-9\u0660-\u0669\u06F0-\u06F9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE7-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29]/
xmlCharacterClasses.letter.test('unicorn');
//=> true
xmlCharacterClasses.letter.test('#');
//=> false
Contains the following regular expressions for matching the different character classes in the XML spec.
letter
baseChar
ideographic
combiningChar
digit
extender
FAQs
Regular expressions for matching against the XML Character Classes
The npm package xml-char-classes receives a total of 142,542 weekly downloads. As such, xml-char-classes popularity was classified as popular.
We found that xml-char-classes 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
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.