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

0.0.4 • Public • Published

VAMTIGER Regex HTML HREF

VAMTIGER Regex HTML HREF will match an href for a defined html string.

Installation

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

npm i --save vamtiger-regex-html-href

or

yarn add vamtiger-regex-html-href

Usage

Import or require a referece to VAMTIGER Regex HTML HREF:

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

or

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

VAMTIGER Regex HTML HREF will return a list of linked stylesheets for defined HTML document text.:

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

const html = `
<!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>
    <link href="some/stylesheet/link/index.css" rel="stylesheet">
</head>
<body>
    <div>
        Some HTML body inner HTML
    </div>
</body>
</html>`;
const match = html.match(regex);

/*
 * if (match)
 *     match[1] = 'some/stylesheet/link/index.css'
 */

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 html = `
<!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>
    <link href="some/stylesheet/link/index.css" rel="stylesheet">
</head>
<body>
    <div>
        Some HTML body inner HTML
    </div>
</body>
</html>`;
const match = XRegExp.exec(input, regex);
// const match: Match = XRegExp.exec(input, regex); // Typescript

/**
 * if (match)
 *     match.href === 'some/stylesheet/link/index.css'
 **/

Readme

Keywords

Package Sidebar

Install

npm i vamtiger-regex-html-href

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

9.28 kB

Total Files

12

Last publish

Collaborators

  • vamtiger-project