vamtiger-regex-html-title
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

VAMTIGER Regex HTML Title

A regular expression to match an HTML title for a defined input string.

Installation

VAMTIGER Regex HTML Title can be installed using npm or yarn:

npm i --save vamtiger-regex-html-title

or

yarn add vamtiger-regex-html-title

Usage

Import or require a referece to VAMTIGER Regex HTML Title:

import regex from 'vamtiger-regex-html-title';

or

const regex = require('vamtiger-regex-html-title').default;

VAMTIGER Regex HTML Title can then be used to test whether a defined input string contains a HTML Title:

const regex = require('vamtiger-regex-html-title').default;

const input = `
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Some HTML Title</title>
</head>
<body>

</body>
</html>
`;
const match = input.match(regex);

/**
 * if (match) {
 *     // Yep, the input string has a HTML title
 *     match[1] === 'Some HTML Title'
 * }
 **/

Named capture groups can be referenced when used together with XRegExp:

const XRegExp = require('xregexp');
const regex = require('vamtiger-regex-html-title').default;
// import {default as regex, Match} from 'vamtiger-regex-html-title'; // Typescript
const input = `
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Some HTML Title</title>
</head>
<body>

</body>
</html>
`;
const match = XRegExp.exec(input, regex);
// const match: Match = XRegExp.exec(input, regex); // Typescript

/**
 * if (match) {
 *     // Yep, the input string has a HTML title
 *     match.title === 'Some HTML Title'
 * }
 **/

Package Sidebar

Install

npm i vamtiger-regex-html-title

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

9.15 kB

Total Files

13

Last publish

Collaborators

  • vamtiger-project