Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filename-regex

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filename-regex

Regular expression for matching file names, with or without extension.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is filename-regex?

The filename-regex npm package is used to match the filename part of a file path. It provides a simple regular expression for extracting filenames from paths, which can be useful in various file manipulation and validation tasks.

What are filename-regex's main functionalities?

Extract Filename from Path

This feature allows you to extract the filename from a given file path using a regular expression.

const filenameRegex = require('filename-regex');
const path = '/path/to/file.txt';
const match = path.match(filenameRegex());
console.log(match[0]); // Output: 'file.txt'

Validate Filename

This feature allows you to validate if a given string is a valid filename using the regular expression provided by the package.

const filenameRegex = require('filename-regex');
const filename = 'file.txt';
const isValid = filenameRegex().test(filename);
console.log(isValid); // Output: true

Other packages similar to filename-regex

Keywords

FAQs

Package last updated on 28 Apr 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc