vamtiger-regex-html-href
A regular expression to match an href for a defined html string.
Last updated 2 years ago by vamtiger-project .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vamtiger-regex-html-href 
SYNC missed versions from official npm registry.

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'
 **/

Current Tags

  • 0.0.4                                ...           latest (2 years ago)

2 Versions

  • 0.0.4                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 2
Dependencies (1)
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |