InsightConnect Marketplace

Advanced Regex

Back to Marketplace

Advanced Regex

v1.0.3

Perform advanced regular expression operations on a string using Python regex

Tags: data manipulation, utility


Actions
  • Data Extraction
  • Search and Replace
  • Split by Regex

Description

The Advanced Regex plugin is used to extract or manipulate targeted text using regular expressions operations on a string using Python specific regex.

Key Features

  • Data extraction
  • Search and replace text
  • Split text

Requirements

This plugin does not contain any requirements.

Documentation

Setup

This plugin does not contain a connection.

Technical Details

Actions

Data Extraction

This action is used to extract data via regex from a string.

Input
Name Type Default Required Description Enum Example
ascii boolean False False Make \w \W \b \B follow ASCII rules None False
dotall boolean False False Make . match newline None True
ignorecase boolean False False Make regex non-case sensitive None True
in_regex string None True Regex to use for data extraction None lorem
in_string string None True Input string None Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Aliquam sapien ex, lorems odales
multiline boolean False False Make begin/end consider each line None True

Example input:

{
  "ascii": false,
  "dotall": true,
  "ignorecase": true,
  "in_regex": "((lo)r(em))",
  "in_string": "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, lorems odales sed luctus ac, dapibus quis augue. Vivamus in cursus libero. (Donec vehicula turpis eu ante viverra, id lacinia.",
  "multiline": true
}
Output
Name Type Required Description
matches [][]string True An array of string arrays matching the output of Python re.findall()

Example output:

{
  "matches": [
    "Lorem",
    "lorem"
  ]
}

Search and Replace

This action is used to regex search and replace string.

Input
Name Type Default Required Description Enum Example
ascii boolean False False Make \w \W \b \B follow ASCII rules None False
dotall boolean False False Make . match newline None True
ignorecase boolean False False Make regex non-case sensitive None True
in_regex string None True Regex to match None lorem
in_string string None True Input string None Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Aliquam sapien ex, lorems odales
max_replace integer 0 False Max occurrences to replace - if zero all will be replaced None 0
multiline boolean False False Make begin/end consider each line None True
replace_string string None False The string to replace matches with None REPLACED

Example input:

{
  "ascii": false,
  "dotall": true,
  "ignorecase": true,
  "in_regex": "lorem",
  "in_string": "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, lorems odales sed luctus ac, dapibus quis augue. Vivamus in cursus libero. Donec vehicula turpis eu ante viverra, id lacinia.",
  "max_replace": 0,
  "multiline": true,
  "replace_string": "REPLACED"
}
Output
Name Type Required Description
result string True The result of the replace operation

Example output:

{
  "result": "REPLACED ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, REPLACEDs odales sed luctus ac, dapibus quis augue. Vivamus in cursus libero. Donec vehicula turpis eu ante viverra, lacinia."
}

Split by Regex

This action is used to split a string into array using regex.

Input
Name Type Default Required Description Enum Example
ascii boolean False False Make \w \W \b \B follow ASCII rules None False
dotall boolean False False Make . match newline None True
ignorecase boolean False False Make regex non-case sensitive None True
in_regex string None True Regex to split string on matches None lorem
in_string string None True Input string None Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Aliquam sapien ex, lorems odales sed
max_split integer 0 False Max splits - if non-zero last element is remainder of string None 0
multiline boolean False False Make begin/end consider each line None True

Example input:

{
  "ascii": false,
  "dotall": true,
  "ignorecase": true,
  "in_regex": "lorem",
  "in_string": "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, lorems odales sed luctus ac, dapibus quis augue. Vivamus in cursus libero. Donec vehicula turpis eu ante viverra, id lacinia.",
  "max_split": 0,
  "multiline": true
}
Output
Name Type Required Description
result []string True An array of the strings returned by the split operation

Example output:

{
  "result": [
    "",
    " ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, ",
    "s odales sed luctus ac, dapibus quis augue. Vivamus in cursus libero. Donec vehicula turpis eu ante viverra, lacinia."
  ]
}

Triggers

This plugin does not contain any triggers.

Custom Output Types

This plugin does not contain any custom output types.

Troubleshooting

This plugin does not contain any troubleshooting information.

Version History

  • 1.0.3 - Update to make replace string non-required
  • 1.0.2 - Update to v4 Python plugin runtime | Add example inputs
  • 1.0.1 - New spec and help.md format for the Extension Library
  • 1.0.0 - Initial plugin

Links

References

plugin_spec_version: v2
extension: plugin
products: [insightconnect]
name: advanced_regex
title: Advanced Regex
description: Perform advanced regular expression operations on a string using Python regex
version: 1.0.3
support: community
vendor: rapid7
status: []
resources:
  source_url: https://github.com/rapid7/insightconnect-plugins/tree/master/advanced_regex
  license_url: https://github.com/rapid7/insightconnect-plugins/blob/master/LICENSE
tags:
- data manipulation
- utility
hub_tags:
  use_cases: [data_utility]
  keywords: [data manipulation, utility]
  features: []
enable_cache: true
language: python

actions:
  data_extraction:
    title: Data Extraction
    description: Extract data via regex from a string
    input:
      in_string:
        title: Input String
        description: Input string
        type: string
        required: true
        example: "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, lorems odales"
      in_regex:
        title: Regex
        description: Regex to use for data extraction
        type: string
        required: true
        example: "lorem"
      ignorecase:
        title: Ignore Case
        description: Make regex non-case sensitive
        type: boolean
        required: false
        default: false
        example: true
      multiline:
        title: Multiline
        description: Make begin/end consider each line
        type: boolean
        required: false
        default: false
        example: true
      dotall:
        title: Dot All
        description: Make . match newline
        type: boolean
        required: false
        default: false
        example: true
      ascii:
        title: ASCII
        description: Make \w \W \b \B follow ASCII rules
        type: boolean
        required: false
        default: false
        example: false
    output:
      matches:
        title: Matches
        description: An array of string arrays matching the output of Python re.findall()
        type: "[][]string"
        required: true
  replace:
    title: Search and Replace
    description: Regex search and replace string
    input:
      in_string:
        title: Input String
        description: Input string
        type: string
        required: true
        example: "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, lorems odales"
      replace_string:
        title: New String
        description: The string to replace matches with
        type: string
        required: false
        example: "REPLACED"
      in_regex:
        title: Regex
        description: Regex to match
        type: string
        required: true
        example: "lorem"
      max_replace:
        title: Max Replace
        description: Max occurrences to replace - if zero all will be replaced
        type: integer
        required: false
        default: 0
        example: 0
      ignorecase:
        title: Ignore Case
        description: Make regex non-case sensitive
        type: boolean
        required: false
        default: false
        example: true
      multiline:
        title: Multiline
        description: Make begin/end consider each line
        type: boolean
        required: false
        default: false
        example: true
      dotall:
        title: Dot All
        description: Make . match newline
        type: boolean
        required: false
        default: false
        example: true
      ascii:
        title: ASCII
        description: Make \w \W \b \B follow ASCII rules
        type: boolean
        required: false
        default: false
        example: false
    output:
      result:
        title: Result String
        description: The result of the replace operation
        type: string
        required: true
  split:
    title: Split by Regex
    description: Split a string into array using regex
    input:
      in_string:
        title: Input String
        description: Input string
        type: string
        required: true
        example: "Lorem ipsum dolor sit amet, consectetur \nadipiscing elit. Aliquam sapien ex, lorems odales sed"
      in_regex:
        title: Regex
        description: Regex to split string on matches
        type: string
        required: true
        example: "lorem"
      max_split:
        title: Max Split
        description: Max splits - if non-zero last element is remainder of string
        type: integer
        required: false
        default: 0
        example: 0
      ignorecase:
        title: Ignore Case
        description: Make regex non-case sensitive
        type: boolean
        required: false
        default: false
        example: true
      multiline:
        title: Multiline
        description: Make begin/end consider each line
        type: boolean
        required: false
        default: false
        example: true
      dotall:
        title: Dot All
        description: Make . match newline
        type: boolean
        required: false
        default: false
        example: true
      ascii:
        title: ASCII
        description: Make \w \W \b \B follow ASCII rules
        type: boolean
        required: false
        default: false
        example: false
    output:
      result:
        title: Result Strings
        description: An array of the strings returned by the split operation
        type: "[]string"
        required: true
Other plugins
McAfee Advanced Threat Defense
Rapid7   |   v1.5.0
Plugin
Get
Ivanti Security Controls
Rapid7   |   v1.3.0
Plugin
Get
Base64
Rapid7   |   v1.1.5
Plugin
Get
Fortinet FortiGate
Rapid7   |   v4.0.2
Plugin
Get
Jira
Rapid7   |   v6.0.0
Plugin
Get