# Welcome

### Welcome to the regex-simplify docs

**For start see how install the module:**

{% content-ref url="/pages/uZW3fqHxxgBXTE2AqrCh" %}
[Installation and establishment](/installation-and-establishment)
{% endcontent-ref %}

**Or see all regex category of the module**

{% content-ref url="/pages/PqB8ChBZTK0a2vMlrTPr" %}
[Global](/docs/global)
{% endcontent-ref %}

{% content-ref url="/pages/nZoXUP6H4eW42qrVoAPD" %}
[Web](/docs/web)
{% endcontent-ref %}

{% content-ref url="/pages/LvinDqXwDEF3BiygjjMk" %}
[Discord](/docs/discord)
{% endcontent-ref %}

{% content-ref url="/pages/njr1DWeSN79IzVqOSVZm" %}
[Password](/docs/password)
{% endcontent-ref %}

{% content-ref url="/pages/5xMi0PDUSVvJNOOPoTIm" %}
[Regex](/docs/regex)
{% endcontent-ref %}


# Installation and establishment

#### You can simply install the dependency to your project with Npm:

```shell
npm install regex-simplify
```

#### Or with yarn:

```shell
yarn add regex-simplify
```

#### Import the module in your code

```javascript
// ES6 (includes typings)
import regex from 'regex-simplify';

// CommonJS
const regex = require('regex-simplify');
```

:warning: **All functions returns this object:**

```typescript
{
    include: true | false, // If the string matched with the regex
    matchs: RegExpMatchArray | null, // An array of all match
    groups: Array<Object | null> | null, // An array of all groups for get parts of the matched string
}
```


# Global

{% content-ref url="/pages/TuEWfgcznZo1ARjcnTDb" %}
[unicodeEmoji](/docs/global/unicodeemoji)
{% endcontent-ref %}


# unicodeEmoji

{% tabs %}
{% tab title="Function types" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>unicodeEmoji(emoji: string): { 
</strong>    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array&#x3C;null>
}
</code></pre>

{% endtab %}

{% tab title="Code example" %}
**Search unicode emoji in a string:**

```javascript
const { global } = require('regex-simplify');

const emoji = global.unicodeEmoji(`
    😁
    test
    :u200b:
    🌮
`);

console.log(emoji);
```

{% endtab %}

{% tab title="Function return" %}
**And here what return the function:**

```javascript
{ 
    include: true, 
    matchs: [ '😁', '🌮' ], 
    groups: [ null, null ] 
}
```

{% endtab %}
{% endtabs %}


# rgb

{% tabs %}
{% tab title="Function types" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>rgb(color: string): { 
</strong>    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array&#x3C;{ 
        R: string | undefined,
        G: string | undefined,
        B: string | undefined,
        A: string | undefined
    } | null> | null
}
</code></pre>

{% endtab %}

{% tab title="Code example" %}
**Search rgb color in a string:**

<pre class="language-javascript"><code class="lang-javascript"><strong>const { global } = require('regex-simplify');
</strong>
const color = global.rgb(`
    rgb(12, 255, 56)
    rgba(12, 255, 56, 0.5)
`)

console.log(color);
</code></pre>

{% endtab %}

{% tab title="Function return" %}
**And here what return the function:**

```javascript
{
  include: true,
  matchs: [ 'rgb(12, 255, 56)', 'rgba(12, 255, 56, c0.5)' ],
  groups: [
    [Object: null prototype] {
      R: '12',
      G: '255',
      B: '56',
      A: undefined
    },
    [Object: null prototype] {
      R: '12', 
      G: '255', 
      B: '56', 
      A: '0.5' 
    }
  ]
}
```

{% endtab %}
{% endtabs %}


# hex

{% tabs %}
{% tab title="Function types" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>hex(color: string): { 
</strong>    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array&#x3C;{ 
        color: string | undefined
    } | null> | null
}
</code></pre>

{% endtab %}

{% tab title="Code example" %}
**Search hex color in a string:**

<pre class="language-javascript"><code class="lang-javascript"><strong>const { global } = require('regex-simplify');
</strong>
const color = global.hex(`
    #F56
    0xF56
`)

console.log(color);
</code></pre>

{% endtab %}

{% tab title="Function return" %}
**And here what return the function:**

```javascript
{
  include: true,
  matchs: [ '#F56', '0xF56' ],
  groups: [
    [Object: null prototype] { color: 'F56' },
    [Object: null prototype] { color: 'F56' }
  ]
}
```

{% endtab %}
{% endtabs %}


# hsl

{% tabs %}
{% tab title="Function types" %}

```typescript
hsl(color: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ 
        hue: string | undefined,
        saturation: string | undefined,
        lightness: string | undefined
    } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search hsl color in a string:**

<pre class="language-javascript"><code class="lang-javascript"><strong>const { global } = require('regex-simplify');
</strong>
const color = global.hsl(`
    hsl(123, 45%, 67%)
`)

console.log(color);
</code></pre>

{% endtab %}

{% tab title="Function return" %}
**And here what return the function:**

```javascript
{
  include: true,
  matchs: [ 'hsl(123, 45%, 67%)' ],
  groups: [
    [Object: null prototype] {     
      hue: '123',
      saturation: '45%',
      lightness: '67%'
    }
  ]
}
```

{% endtab %}
{% endtabs %}


# Web

{% content-ref url="/pages/6PHK83cgcMvUffUiMLUs" %}
[link](/docs/web/link)
{% endcontent-ref %}

{% content-ref url="/pages/badWl5JmqPNpamO7xo77" %}
[E-mail](/docs/web/e-mail)
{% endcontent-ref %}


# link

{% hint style="warning" %}
The regex keeps the protocol optional, so some links can be false positives. \
In a future version you will be able to choose if you want to force a protocol or leave the protocol optional
{% endhint %}

{% tabs %}
{% tab title="Function types" %}

<pre class="language-typescript"><code class="lang-typescript"><strong>link(link: string): { 
</strong>    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array&#x3C;{ 
        protocol: string | undefined,
        auth: string | undefined,
        username: string | undefined,
        password: string | undefined,
        alldomain: string,
        subdomain: string | undefined,
        domain: string,
        extension: string,
        ipadress: string | undefined,
        port: string | undefined,
        route: string | undefined,
        filename: string | undefined,
        query: string | undefined,
        anchor: string | undefined,
    } | null> | null
}
</code></pre>

{% endtab %}

{% tab title="Code example" %}
**Search e-mail in a string:**

```javascript
const { web } = require('regex-simplify');

const link = web.link(`
    https://discord.gg/test/image.png?query=test#anchor
    http://192.168.1.1
    http://192.168.1.1:5555
    http://username:password@domain.com
`);

console.log(link);
```

{% endtab %}

{% tab title="Function return" %}
**And here what return the function:**

```javascript
{
  include: true,
  matchs: [
    'https://discord.gg/test/image.png?query=test#anchor',
    'http://192.168.1.1',
    'http://192.168.1.1:5555',
    'http://username:password@domain.com'
  ],
  groups: [
    [Object: null prototype] {
      protocol: 'https',
      auth: undefined,
      username: undefined,
      password: undefined,
      alldomain: 'discord.gg',
      subdomain: undefined,
      domain: 'discord',
      extension: 'gg',
      ipaddress: undefined,
      port: undefined,
      route: '/test/',
      filename: 'image.png',
      query: '?query=test',
      anchor: '#anchor'
    },
    [Object: null prototype] {
      protocol: 'http',
      auth: undefined,
      username: undefined,
      password: undefined,
      alldomain: '192.168.1.1',
      subdomain: undefined,
      domain: undefined,
      extension: undefined,
      ipaddress: '192.168.1.1',
      port: undefined,
      route: undefined,
      filename: undefined,
      query: undefined,
      anchor: undefined
    },
    [Object: null prototype] {
      protocol: 'http',
      auth: undefined,
      username: undefined,
      password: undefined,
      alldomain: '192.168.1.1',
      subdomain: undefined,
      domain: undefined,
      extension: undefined,
      ipaddress: '192.168.1.1',
      port: '5555',
      route: undefined,
      filename: undefined,
      query: undefined,
      anchor: undefined
    },
    [Object: null prototype] {
      protocol: 'http',
      auth: 'username:password',
      username: 'username',
      password: 'password',
      alldomain: 'domain.com',
      subdomain: undefined,
      domain: 'domain',
      extension: 'com',
      ipaddress: undefined,
      port: undefined,
      route: undefined,
      filename: undefined,
      query: undefined,
      anchor: undefined
    }
  ]
}
```

{% endtab %}
{% endtabs %}


# E-mail

{% tabs %}
{% tab title="Functions types" %}

```typescript
email(email: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ user: string, domain: string } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search e-mail in a string:**

```javascript
const { web } = require('regex-simplify');

const email = web.email(`
    lama.loca.loca123@inca.com
    test@test.co.uk
    test @ outlook.com
`);

console.log(email);
```

{% endtab %}

{% tab title="Function return" %}
**And here what return the function:**

```javascript
{
  include: true,
  matchs: [ 'lama.loca.loca123@inca.com', 'test@test.co.uk' ],     
  groups: [
    [Object: null prototype] {
      user: 'lama.loca.loca123',
      domain: 'inca.com'
    },
    [Object: null prototype] { user: 'test', domain: 'test.co.uk' }
  ]
}
```

{% endtab %}
{% endtabs %}


# Discord

{% content-ref url="/pages/PZqhaLcpKiEqiz7qs6V4" %}
[userMention](/docs/discord/usermention)
{% endcontent-ref %}

{% content-ref url="/pages/fLyL2MZEm5sJdf8DoT8q" %}
[channelMention](/docs/discord/channelmention)
{% endcontent-ref %}

{% content-ref url="/pages/eodaLtXQO9E2EjLg4O21" %}
[roleMention](/docs/discord/rolemention)
{% endcontent-ref %}

{% content-ref url="/pages/WTUHmkK8hd1RpzwPkrg5" %}
[emojiInfo](/docs/discord/emojiinfo)
{% endcontent-ref %}

{% content-ref url="/pages/Mg4W3XGUR2NO6yjDu2Y7" %}
[invite](/docs/discord/invite)
{% endcontent-ref %}


# userMention

{% tabs %}
{% tab title="Function types" %}

```typescript
userMention(user: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ id: string } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search user mention in a string:**

```javascript
const { discord } = require('regex-simplify');

const user = discord.userMention(`
    <@!584749055578603521>
    <@720256732630351912>
    <@507329636305207308>
`);

console.log(user);
```

{% endtab %}

{% tab title="Function return" %}

```javascript
{
  include: true,
  matchs: [
    '<@!584749055578603521>',
    '<@720256732630351912>',
    '<@507329636305207308>'
  ],
  groups: [
    [Object: null prototype] { id: '584749055578603521' },
    [Object: null prototype] { id: '720256732630351912' },
    [Object: null prototype] { id: '507329636305207308' }
  ]
}
```

{% endtab %}
{% endtabs %}


# channelMention

{% tabs %}
{% tab title="Function types" %}

```typescript
channelMention(channel: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ id: string } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search channel mention in a string:**

```javascript
const { discord } = require('regex-simplify');

const channel = discord.channelMention(`
    <#584749055578603521>
    <#720256732630351912>
    <#507329636305207308>
`);

console.log(channel);
```

{% endtab %}

{% tab title="Function return" %}

```javascript
{
  include: true,
  matchs: [
    '<#584749055578603521>',
    '<#720256732630351912>',
    '<#507329636305207308>'
  ],
  groups: [
    [Object: null prototype] { id: '584749055578603521' },
    [Object: null prototype] { id: '720256732630351912' },
    [Object: null prototype] { id: '507329636305207308' }
  ]
}
```

{% endtab %}
{% endtabs %}


# roleMention

{% tabs %}
{% tab title="Function types" %}

```typescript
roleMention(role: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ id: string } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search role mention in a string:**

```javascript
const { discord } = require('regex-simplify');

const role = discord.roleMention(`
    <@&783057923076653136>
    <@&830426254977138688>
    <@&830426294890004490>
`);

console.log(role);
```

{% endtab %}

{% tab title="Function return" %}

```javascript
{
  include: true,
  matchs: [
    '<@&783057923076653136>',
    '<@&830426254977138688>',
    '<@&830426294890004490>'
  ],
  groups: [
    [Object: null prototype] { id: '783057923076653136' },
    [Object: null prototype] { id: '830426254977138688' },
    [Object: null prototype] { id: '830426294890004490' } 
  ]
}
```

{% endtab %}
{% endtabs %}


# emojiInfo

{% tabs %}
{% tab title="Function types" %}

```typescript
emojiInfo(emoji: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ animated: 'a' | undefined, name: string, id: string } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search emoji information in a string:**

```javascript
const { discord } = require('regex-simplify');

const emoji = discord.emojiInfo(`
    <:booster:858775773876060160>
    <:ping:833077145773277214>
    <a:all_badges:851127998270930964>
`);

console.log(emoji);
```

{% endtab %}

{% tab title="Function return" %}

```javascript
{
  include: true,
  matchs: [
    '<:booster:858775773876060160>',   
    '<:ping:833077145773277214>',      
    '<a:all_badges:851127998270930964>'
  ],
  groups: [
    [Object: null prototype] {
      animated: undefined,
      name: 'booster',
      id: '858775773876060160'
    },
    [Object: null prototype] {
      animated: undefined,
      name: 'ping',
      id: '833077145773277214'
    },
    [Object: null prototype] {
      animated: 'a',
      name: 'all_badges',
      id: '851127998270930964'
    }
  ]
}
```

{% endtab %}
{% endtabs %}


# invite

{% tabs %}
{% tab title="Function types" %}

```typescript
invite(link: string): { 
    include: boolean, 
    matchs: RegExpMatchArray | null, 
    groups: Array<{ code: string } | null> | null
}
```

{% endtab %}

{% tab title="Code example" %}
**Search user mention in a string:**

```javascript
const { discord } = require('regex-simplify');

const invite = discord.invite(`
    https://discord.gg/7prqAjux
    https://discord.com/invite/7prqAjux
    discord.gg/7prqAjux
    https://discord.com/7prqAjux
`);

console.log(invite);
```

{% endtab %}

{% tab title="Function return" %}

```javascript
{
  include: true,
  matchs: [
    'discord.gg/7prqAjux',
    'discord.com/invite/7prqAjux',
    'discord.gg/7prqAjux'
  ],
  groups: [
    [Object: null prototype] { code: '7prqAjux' },
    [Object: null prototype] { code: '7prqAjux' },
    [Object: null prototype] { code: '7prqAjux' }
  ]
}
```

{% endtab %}
{% endtabs %}


# Password

### :construction: SOON :construction:

This part of the doc is not fully stable and developped


# Regex

You would a regex of the module ? But without use functions of the module ?\
No problem

Import regex

```javascript
const { regex } = require('regex-simplify');
```

And use the regex you would 😁

**4 category available:**

<details>

<summary>Global</summary>

* unicodeEmoji

</details>

<details>

<summary>Discord</summary>

* userMention
* channelMention
* roleMention
* emoji
* invite

</details>

<details>

<summary>Web</summary>

* link
* email

</details>

<details>

<summary>Password</summary>

*This part is not yet fully operationa*l

* lowPassword
* mediumPassword
* highPassword

</details>


# Contact me

### You would contact me ?

\
**Discord:** LACOSTAR91#3788

**Github:** [LACOSTAR91](https://github.com/LACOSTAR91) (Don't forgot to follow me :smile:)


# Contribute

### You would contribute to the module ?

To contribute you can open a Pull Request to contribute by coding the module

{% embed url="<https://github.com/LACOSTAR91/regex-simplify/pulls>" %}
Github repo pull requests
{% endembed %}

Or you can open an Issue to contribute by giving ideas, reporting bugs, or other things

{% embed url="<https://github.com/LACOSTAR91/regex-simplify/issues>" %}
Github repo issues
{% endembed %}

*And don't forgot to* :star: *the repo* :tada:


# Todo

Voici la to-do list du module si vous souhaiter contribuer

* Phone numbers

* ZIP codes

* IP addresses

* MAC addresses

* Hexadecimal (0x + #), RGB, HSL colors

* Add strict option on functions for keep the choice for users if would one matches or all matches in the string


