Naughty Praying Mantis

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

    0.0.5 • Public • Published

    VAMTIGER Regex HTML Body Inner HTML

    A regular expression to match the body inner HTML title for a defined HTML input string.

    Installation

    VAMTIGER Regex HTML Body Inner HTML can be installed using npm or yarn:

    npm i --save vamtiger-regex-html-body-inner-html

    or

    yarn add vamtiger-regex-html-body-inner-html

    Usage

    Import or require a referece to VAMTIGER Regex HTML Body Inner HTML:

    import regex from 'vamtiger-regex-html-body-inner-html';

    or

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

    VAMTIGER Regex HTML Body Inner HTML can be used to match the body inner HTML title for a defined HTML input string:

    const regex = require('vamtiger-regex-html-body-inner-html').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>
        <div>
            Some HTML body inner HTML
        </div>
    </body>
    </html>
    `;
    const match = input.match(regex);
     
    /**
     * if (match) {
     *     // Yep, the input string has a HTML title
     *     match[1] === '<body>'
     *     match[2] === `
     *          <div>
     *               Some HTML body inner HTML
     *          </div>`
     *     match[3] === '</body>'
     * }
     **/

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

    const XRegExp = require('xregexp');
    const regex = require('vamtiger-regex-html-body-inner-html').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>
        <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) {
     *     // Yep, the input string has a HTML title
     *     match.openingBodyTag === '<body>'
     *     match.innerHtml === `
     *          <div>
     *               Some HTML body inner HTML
     *          </div>`
     *     match.closingBodyTag === '</body>'
     * }
     **/

    Install

    npm i vamtiger-regex-html-body-inner-html

    DownloadsWeekly Downloads

    2

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    11.4 kB

    Total Files

    12

    Last publish

    Collaborators

    • vamtiger-project