comment-regex

WebJar for comment-regex

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

comment-regex
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

comment-regex
WebJar for comment-regex
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/comment-regex

Download comment-regex

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/comment-regex/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>comment-regex</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/comment-regex/
implementation 'org.webjars.npm:comment-regex:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/comment-regex/
implementation ("org.webjars.npm:comment-regex:1.0.1")
'org.webjars.npm:comment-regex:jar:1.0.1'
<dependency org="org.webjars.npm" name="comment-regex" rev="1.0.1">
  <artifact name="comment-regex" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='comment-regex', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "comment-regex" % "1.0.1"
[org.webjars.npm/comment-regex "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

comment-regex

Regular expression for matching JavaScript comments

This is pretty fragile and created for performance reasons where using a real parser would be overkill.

Install

$ npm install comment-regex

Usage

const commentRegex = require('comment-regex');

// Contains a comment
commentRegex().test('/* unicorn */\nvar foo = true;');
//=> true

// Get the contents of a comment
commentRegex().exec('/* unicorn */\nvar foo = true;')[2].trim();

// Get all the comments
'/* unicorn */\nvar foo = true;\nvar unicorn = "rainbows"; // rainbow'.match(commentRegex());
//=> ['/* unicorn */', ' // rainbow']

API

The contents of the comment is in the first submatch.

commentRegex()

Returns a regex for matching line and block comments.

commentRegex.line()

Returns a regex for matching line comments.

commentRegex.block()

Returns a regex for matching block comments.

License

MIT © Sindre Sorhus

Versions

Version
1.0.1