Regular Expressions 101

Save & Manage Regex

  • Current Version: 3
  • Save & Share
  • Community Library

Flavor

  • PCRE2 (PHP)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java
  • .NET 7.0 (C#)
  • Rust
  • PCRE (Legacy)
  • Regex Flavor Guide

Function

  • Match
  • Substitution
  • List
  • Unit Tests
Sponsors
There are currently no sponsors. Become a sponsor today!
An explanation of your regex will be automatically generated as you type.
Detailed match information will be displayed here automatically.
  • All Tokens
  • Common Tokens
  • General Tokens
  • Anchors
  • Meta Sequences
  • Quantifiers
  • Group Constructs
  • Character Classes
  • Flags/Modifiers
  • Substitution
  • A single character of: a, b or c
    [abc]
  • A character except: a, b or c
    [^abc]
  • A character in the range: a-z
    [a-z]
  • A character not in the range: a-z
    [^a-z]
  • A character in the range: a-z or A-Z
    [a-zA-Z]
  • Any single character
    .
  • Alternate - match either a or b
    a|b
  • Any whitespace character
    \s
  • Any non-whitespace character
    \S
  • Any digit
    \d
  • Any non-digit
    \D
  • Any word character
    \w
  • Any non-word character
    \W
  • Non-capturing group
    (?:...)
  • Capturing group
    (...)
  • Zero or one of a
    a?
  • Zero or more of a
    a*
  • One or more of a
    a+
  • Exactly 3 of a
    a{3}
  • 3 or more of a
    a{3,}
  • Between 3 and 6 of a
    a{3,6}
  • Start of string
    ^
  • End of string
    $
  • A word boundary
    \b
  • Non-word boundary
    \B

Regular Expression
Processing...

Test String

Code Generator

Generated Code

import re regex = re.compile(r"menuentry\s+\"?[[:alnum:] ]+\"?\s+{\n([[:print:]\t]+(?<!disabled)\n)+}", flags=re.DOTALL) test_str = ("#\n" "# refind.conf\n" "# Configuration file for the rEFInd boot menu\n" "#\n\n" "# Timeout in seconds for the main menu screen. Setting the timeout to 0\n" "# disables automatic booting (i.e., no timeout). Setting it to -1 causes\n" "# an immediate boot to the default OS *UNLESS* a keypress is in the buffer\n" "# when rEFInd launches, in which case that keypress is interpreted as a\n" "# shortcut key. If no matching shortcut is found, rEFInd displays its\n" "# menu with no timeout.\n" "#\n" "timeout 2\n\n" "# Set the logging level. When set to 0, rEFInd does not log its actions.\n" "# When set to 1 or above, rEFInd creates a file called refind.log in\n" "# its home directory on the ESP and records information about what it's\n" "# doing. Higher values record more information, up to a maximum of 4.\n" "# This token should be left at the default of 0 except when debugging\n" "# problems.\n" "# Default value is 0\n" "#\n" "#log_level 1\n\n" "# Normally, when the timeout period has passed, rEFInd boots the\n" "# default_selection. If the following option is uncommented, though,\n" "# rEFInd will instead attempt to shut down the computer.\n" "# CAUTION: MANY COMPUTERS WILL INSTEAD HANG OR REBOOT! Macs and more\n" "# recent UEFI-based PCs are most likely to work with this feature.\n" "# Default value is true\n" "#\n" "#shutdown_after_timeout\n\n" "# Whether to store rEFInd's rEFInd-specific variables in NVRAM (1, true,\n" "# or on) or in files in the \"vars\" subdirectory of rEFInd's directory on\n" "# disk (0, false, or off). Using NVRAM works well with most computers;\n" "# however, it increases wear on the motherboard's NVRAM, and if the EFI\n" "# is buggy or the NVRAM is old and worn out, it may not work at all.\n" "# Storing variables on disk is a viable alternative in such cases, or\n" "# if you want to minimize wear and tear on the NVRAM; however, it won't\n" "# work if rEFInd is stored on a filesystem that's read-only to the EFI\n" "# (such as an HFS+ volume), and it increases the risk of filesystem\n" "# damage. Note that this option affects ONLY rEFInd's own variables,\n" "# such as the PreviousBoot, HiddenTags, HiddenTools, and HiddenLegacy\n" "# variables. It does NOT affect Secure Boot or other non-rEFInd\n" "# variables.\n" "# Default is true\n" "#\n" "use_nvram false\n\n" "# Screen saver timeout; the screen blanks after the specified number of\n" "# seconds with no keyboard input. The screen returns after most keypresses\n" "# (unfortunately, not including modifier keys such as Shift, Control, Alt,\n" "# or Option). Setting a value of \"-1\" causes rEFInd to start up with its\n" "# screen saver active. The default is 0, which disables the screen saver.\n" "#\n" "#screensaver 300\n\n" "# Hide user interface elements for personal preference or to increase\n" "# security:\n" "# banner - the rEFInd title banner (built-in or loaded via \"banner\")\n" "# label - boot option text label in the menu\n" "# singleuser - remove the submenu options to boot macOS in single-user\n" "# or verbose modes; affects ONLY macOS\n" "# safemode - remove the submenu option to boot macOS in \"safe mode\"\n" "# hwtest - the submenu option to run Apple's hardware test\n" "# arrows - scroll arrows on the OS selection tag line\n" "# hints - brief command summary in the menu\n" "# editor - the options editor (+, F2, or Insert on boot options menu)\n" "# badges - device-type badges for boot options\n" "# all - all of the above\n" "# Default is none of these (all elements active)\n" "#\n" "#hideui singleuser\n" "#hideui all\n\n" "# Set the name of a subdirectory in which icons are stored. Icons must\n" "# have the same names they have in the standard directory. The directory\n" "# name is specified relative to the main rEFInd binary's directory. If\n" "# an icon can't be found in the specified directory, an attempt is made\n" "# to load it from the default directory; thus, you can replace just some\n" "# icons in your own directory and rely on the default for others.\n" "# Icon files may be in any supported format -- ICNS (*.icns), BMP (*.bmp),\n" "# PNG (*.png), or JPEG (*.jpg or *.jpeg); however, rEFInd's BMP and JPEG\n" "# implementations do not support transparency, which is highly desirable\n" "# in icons.\n" "# Default is \"icons\".\n" "#\n" "#icons_dir myicons\n" "#icons_dir icons/snowy\n\n" "# Use a custom title banner instead of the rEFInd icon and name. The file\n" "# path is relative to the directory where refind.efi is located. The color\n" "# in the top left corner of the image is used as the background color\n" "# for the menu screens. Currently uncompressed BMP images with color\n" "# depths of 24, 8, 4 or 1 bits are supported, as well as PNG and JPEG\n" "# images. (ICNS images can also be used, but ICNS has limitations that\n" "# make it a poor choice for this purpose.) PNG and JPEG support is\n" "# limited by the underlying libraries; some files, like progressive JPEGs,\n" "# will not work.\n" "#\n" "#banner hostname.bmp\n" "#banner mybanner.jpg\n" "#banner icons/snowy/banner-snowy.png\n\n" "# Specify how to handle banners that aren't exactly the same as the screen\n" "# size:\n" "# noscale - Crop if too big, show with border if too small\n" "# fillscreen - Fill the screen\n" "# Default is noscale\n" "#\n" "#banner_scale fillscreen\n\n" "# Icon sizes. All icons are square, so just one value is specified. The\n" "# big icons are used for OS selectors in the first row and the small\n" "# icons are used for tools on the second row. Drive-type badges are 1/4\n" "# the size of the big icons. Legal values are 32 and above. If the icon\n" "# files do not hold icons of the proper size, the icons are scaled to\n" "# the specified size. The default values are 48 and 128 for small and\n" "# big icons, respectively.\n" "#\n" "#small_icon_size 96\n" "#big_icon_size 256\n\n" "# Custom images for the selection background. There is a big one (144 x 144)\n" "# for the OS icons, and a small one (64 x 64) for the function icons in the\n" "# second row. If only a small image is given, that one is also used for\n" "# the big icons by stretching it in the middle. If only a big one is given,\n" "# the built-in default will be used for the small icons. If an image other\n" "# than the optimal size is specified, it will be scaled in a way that may\n" "# be ugly.\n" "#\n" "# Like the banner option above, these options take a filename of an\n" "# uncompressed BMP, PNG, JPEG, or ICNS image file with a color depth of\n" "# 24, 8, 4, or 1 bits. The PNG or ICNS format is required if you need\n" "# transparency support (to let you \"see through\" to a full-screen banner).\n" "#\n" "#selection_big selection-big.bmp\n" "#selection_small selection-small.bmp\n\n" "# Set the font to be used for all textual displays in graphics mode.\n" "# For best results, the font must be a PNG file with alpha channel\n" "# transparency. It must contain ASCII characters 32-126 (space through\n" "# tilde), inclusive, plus a glyph to be displayed in place of characters\n" "# outside of this range, for a total of 96 glyphs. Only monospaced fonts\n" "# are supported. Fonts may be of any size, although large fonts can\n" "# produce display irregularities.\n" "# The default is rEFInd's built-in font, Luxi Mono Regular 12 point.\n" "#\n" "#font myfont.png\n\n" "# Use text mode only. When enabled, this option forces rEFInd into text mode.\n" "# Passing this option a \"0\" value causes graphics mode to be used. Pasing\n" "# it no value or any non-0 value causes text mode to be used.\n" "# Default is to use graphics mode.\n" "#\n" "#textonly\n\n" "# Set the EFI text mode to be used for textual displays. This option\n" "# takes a single digit that refers to a mode number. Mode 0 is normally\n" "# 80x25, 1 is sometimes 80x50, and higher numbers are system-specific\n" "# modes. Mode 1024 is a special code that tells rEFInd to not set the\n" "# text mode; it uses whatever was in use when the program was launched.\n" "# If you specify an invalid mode, rEFInd pauses during boot to inform\n" "# you of valid modes.\n" "# CAUTION: On VirtualBox, and perhaps on some real computers, specifying\n" "# a text mode and uncommenting the \"textonly\" option while NOT specifying\n" "# a resolution can result in an unusable display in the booted OS.\n" "# Default is 1024 (no change)\n" "#\n" "#textmode 2\n\n" "# Set the screen's video resolution. Pass this option one of the following:\n" "# * two integer values, corresponding to the X and Y resolutions\n" "# * one integer value, corresponding to a GOP (UEFI) video mode\n" "# * the string \"max\", which sets the maximum available resolution\n" "# Note that not all resolutions are supported. On UEFI systems, passing\n" "# an incorrect value results in a message being shown on the screen to\n" "# that effect, along with a list of supported modes. On EFI 1.x systems\n" "# (e.g., Macintoshes), setting an incorrect mode silently fails. On both\n" "# types of systems, setting an incorrect resolution results in the default\n" "# resolution being used. A resolution of 1024x768 usually works, but higher\n" "# values often don't.\n" "# Default is \"0 0\" (use the system default resolution, usually 800x600).\n" "# Other resolutions: 1920x1080 1680x1050 1440x900 1366x768 1024x600\n" "#\n" "resolution max\n\n" "# Enable touch screen support. If active, this feature enables use of\n" "# touch screen controls (as on tablets). Note, however, that not all\n" "# tablets' EFIs provide the necessary underlying support, so this\n" "# feature may not work for you. If it does work, you should be able\n" "# to launch an OS or tool by touching it. In a submenu, touching\n" "# anywhere launches the currently-selection item; there is, at present,\n" "# no way to select a specific submenu item. This feature is mutually\n" "# exclusive with the enable_mouse feature. If both are uncommented,\n" "# the one read most recently takes precedence.\n" "#\n" "#enable_touch\n\n" "# Enable mouse support. If active, this feature enables use of the\n" "# computer's mouse. Note, however, that not all computers' EFIs\n" "# provide the necessary underlying support, so this feature may not\n" "# work for you. If it does work, you should be able to launch an\n" "# OS or tool by clicking it with the mouse pointer. This feature\n" "# is mutually exclusive with the enable_touch feature. If both\n" "# are uncommented, the one read most recently takes precedence.\n" "#\n" "#enable_mouse\n\n" "# Size of the mouse pointer, in pixels, per side.\n" "# Default is 16\n" "#\n" "#mouse_size 16\n\n" "# Speed of mouse tracking. Higher numbers equate to faster\n" "# mouse movement. This option requires that enable_mouse be\n" "# uncommented.\n" "# Legal values are between 1 and 32. Default is 4.\n" "#\n" "#mouse_speed 4\n\n" "# Launch specified OSes in graphics mode. By default, rEFInd switches\n" "# to text mode and displays basic pre-launch information when launching\n" "# all OSes except macOS. Using graphics mode can produce a more seamless\n" "# transition, but displays no information, which can make matters\n" "# difficult if you must debug a problem. Also, on at least one known\n" "# computer, using graphics mode prevents a crash when using the Linux\n" "# kernel's EFI stub loader. You can specify an empty list to boot all\n" "# OSes in text mode.\n" "# Valid options:\n" "# osx - macOS\n" "# linux - A Linux kernel with EFI stub loader\n" "# elilo - The ELILO boot loader\n" "# grub - The GRUB (Legacy or 2) boot loader\n" "# windows - Microsoft Windows\n" "# Default value: osx\n" "#\n" "use_graphics_for \n\n" "# Which non-bootloader tools to show on the tools line, and in what\n" "# order to display them:\n" "# shell - the EFI shell (requires external program; see rEFInd\n" "# documentation for details)\n" "# memtest - the memtest86 program, in EFI/tools, EFI/memtest86,\n" "# EFI/memtest, EFI/tools/memtest86, or EFI/tools/memtest\n" "# gptsync - the (dangerous) gptsync.efi utility (requires external\n" "# program; see rEFInd documentation for details)\n" "# gdisk - the gdisk partitioning program\n" "# apple_recovery - boots the Apple Recovery HD partition, if present\n" "# windows_recovery - boots an OEM Windows recovery tool, if present\n" "# (see also the windows_recovery_files option)\n" "# mok_tool - makes available the Machine Owner Key (MOK) maintenance\n" "# tool, MokManager.efi, used on Secure Boot systems\n" "# csr_rotate - adjusts Apple System Integrity Protection (SIP)\n" "# policy. Requires \"csr_values\" to be set.\n" "# install - an option to install rEFInd from the current location\n" "# to another ESP\n" "# bootorder - adjust the EFI's (NOT rEFInd's) boot order\n" "# about - an \"about this program\" option\n" "# hidden_tags - manage hidden tags\n" "# exit - a tag to exit from rEFInd\n" "# shutdown - shuts down the computer (a bug causes this to reboot\n" "# many UEFI systems)\n" "# reboot - a tag to reboot the computer\n" "# firmware - a tag to reboot the computer into the firmware's\n" "# user interface (ignored on older computers)\n" "# fwupdate - a tag to update the firmware; launches the fwupx64.efi\n" "# (or similar) program\n" "# netboot - launch the ipxe.efi tool for network (PXE) booting\n" "# Default is shell,memtest,gdisk,apple_recovery,windows_recovery,mok_tool,about,hidden_tags,shutdown,reboot,firmware,fwupdate\n" "#\n" "showtools shell,bootorder,memtest,windows_recovery,reboot,firmware,fwupdate,exit\n\n" "# Tool binaries to be excluded from the tools line, even if the\n" "# general class is specified in showtools. This enables trimming an\n" "# overabundance of tools, as when you see multiple mok_tool entries\n" "# after installing multiple Linux distributions.\n" "# Just as with dont_scan_files, you can specify a filename alone, a\n" "# full pathname, or a volume identifier (filesystem label, partition\n" "# name, or partition GUID) and a full pathname.\n" "# Default is an empty list (nothing is excluded)\n" "#\n" "#dont_scan_tools ESP2:/EFI/ubuntu/mmx64.efi,gptsync_x64.efi\n\n" "# Boot loaders that can launch a Windows restore or emergency system.\n" "# These tend to be OEM-specific.\n" "# Default is LRS_ESP:/EFI/Microsoft/Boot/LrsBootmgr.efi\n" "#\n" "#windows_recovery_files LRS_ESP:/EFI/Microsoft/Boot/LrsBootmgr.efi\n\n" "# Directories in which to search for EFI drivers. These drivers can\n" "# provide filesystem support, give access to hard disks on plug-in\n" "# controllers, etc. In most cases none are needed, but if you add\n" "# EFI drivers and you want rEFInd to automatically load them, you\n" "# should specify one or more paths here. rEFInd always scans the\n" "# \"drivers\" and \"drivers_{arch}\" subdirectories of its own installation\n" "# directory (where \"{arch}\" is your architecture code); this option\n" "# specifies ADDITIONAL directories to scan.\n" "# Default is to scan no additional directories for EFI drivers\n" "#\n" "#scan_driver_dirs EFI/tools/drivers,drivers\n\n" "# Which types of boot loaders to search, and in what order to display them:\n" "# internal - internal EFI disk-based boot loaders\n" "# external - external EFI disk-based boot loaders\n" "# optical - EFI optical discs (CD, DVD, etc.)\n" "# netboot - EFI network (PXE) boot options\n" "# hdbios - BIOS disk-based boot loaders\n" "# biosexternal - BIOS external boot loaders (USB, eSATA, etc.)\n" "# cd - BIOS optical-disc boot loaders\n" "# manual - use stanzas later in this configuration file\n" "# firmware - boot EFI programs set in the firmware's NVRAM\n" "# Note that the legacy BIOS options require firmware support, which is\n" "# not present on all computers.\n" "# The netboot option is experimental and relies on the ipxe.efi and\n" "# ipxe_discover.efi program files.\n" "# On UEFI PCs, default is internal,external,optical,manual\n" "# On Macs, default is internal,hdbios,external,biosexternal,optical,cd,manual\n" "#\n" "scanfor manual,internal,external,optical\n\n" "# By default, rEFInd relies on the UEFI firmware to detect BIOS-mode boot\n" "# devices. This sometimes doesn't detect all the available devices, though.\n" "# For these cases, uefi_deep_legacy_scan results in a forced scan and\n" "# modification of NVRAM variables on each boot. Adding \"0\", \"off\", or\n" "# \"false\" resets to the default value. This token has no effect on Macs or\n" "# when no BIOS-mode options are set via scanfor.\n" "# Default is unset (or \"uefi_deep_legacy_scan false\")\n" "#\n" "#uefi_deep_legacy_scan\n\n" "# Delay for the specified number of seconds before scanning disks.\n" "# This can help some users who find that some of their disks\n" "# (usually external or optical discs) aren't detected initially,\n" "# but are detected after pressing Esc.\n" "# The default is 0.\n" "#\n" "#scan_delay 5\n\n" "# When scanning volumes for EFI boot loaders, rEFInd always looks for\n" "# macOS's and Microsoft Windows' boot loaders in their normal locations,\n" "# and scans the root directory and every subdirectory of the /EFI directory\n" "# for additional boot loaders, but it doesn't recurse into these directories.\n" "# The also_scan_dirs token adds more directories to the scan list.\n" "# Directories are specified relative to the volume's root directory. This\n" "# option applies to ALL the volumes that rEFInd scans UNLESS you include\n" "# a volume name and colon before the directory name, as in \"myvol:/somedir\"\n" "# to scan the somedir directory only on the filesystem named myvol. If a\n" "# specified directory doesn't exist, it's ignored (no error condition\n" "# results). The default is to scan the \"boot\" directory in addition to\n" "# various hard-coded directories.\n" "#\n" "#also_scan_dirs boot,ESP2:EFI/linux/kernels\n\n" "# Partitions (or whole disks, for legacy-mode boots) to omit from scans.\n" "# For EFI-mode scans, you normally specify a volume by its label, which you\n" "# can obtain in an EFI shell by typing \"vol\", from Linux by typing\n" "# \"blkid /dev/{devicename}\", or by examining the disk's label in various\n" "# OSes' file browsers. It's also possible to identify a partition by its\n" "# unique GUID (aka its \"PARTUUID\" in Linux parlance). (Note that this is\n" "# NOT the partition TYPE CODE GUID.) This identifier can be obtained via\n" "# \"blkid\" in Linux or \"diskutil info {partition-id}\" in macOS.\n" "# For legacy-mode scans, you can specify any subset of the boot loader\n" "# description shown when you highlight the option in rEFInd.\n" "# The default is \"LRS_ESP\".\n" "#\n" "#dont_scan_volumes \"Recovery HD\"\n\n" "# Directories that should NOT be scanned for boot loaders. By default,\n" "# rEFInd doesn't scan its own directory, the EFI/tools directory, the\n" "# EFI/memtest directory, the EFI/memtest86 directory, or the\n" "# com.apple.recovery.boot directory. Using the dont_scan_dirs option\n" "# enables you to \"blacklist\" other directories; but be sure to use \"+\"\n" "# as the first element if you want to continue blacklisting existing\n" "# directories. You might use this token to keep EFI/boot/bootx64.efi out\n" "# of the menu if that's a duplicate of another boot loader or to exclude\n" "# a directory that holds drivers or non-bootloader utilities provided by\n" "# a hardware manufacturer. If a directory is listed both here and in\n" "# also_scan_dirs, dont_scan_dirs takes precedence. Note that this\n" "# blacklist applies to ALL the filesystems that rEFInd scans, not just\n" "# the ESP, unless you precede the directory name by a filesystem name or\n" "# partition unique GUID, as in \"myvol:EFI/somedir\" to exclude EFI/somedir\n" "# from the scan on the myvol volume but not on other volumes.\n" "#\n" "dont_scan_dirs +ESP-COMET:/EFI/Boot,EFI/Microsoft/Boot,EFI/systemd\n\n" "# Files that should NOT be included as EFI boot loaders (on the\n" "# first line of the display). If you're using a boot loader that\n" "# relies on support programs or drivers that are installed alongside\n" "# the main binary or if you want to \"blacklist\" certain loaders by\n" "# name rather than location, use this option. Note that this will\n" "# NOT prevent certain binaries from showing up in the second-row\n" "# set of tools. Most notably, various Secure Boot and recovery\n" "# tools are present in this list, but may appear as second-row\n" "# items.\n" "# The file may be specified as a bare name (e.g., \"notme.efi\"), as\n" "# a complete pathname (e.g., \"/EFI/somedir/notme.efi\"), or as a\n" "# complete pathname with volume (e.g., \"SOMEDISK:/EFI/somedir/notme.efi\"\n" "# or 2C17D5ED-850D-4F76-BA31-47A561740082:/EFI/somedir/notme.efi\").\n" "# OS tags hidden via the Delete or '-' key in the rEFInd menu are\n" "# added to this list, but stored in NVRAM.\n" "# The default is shim.efi,shim-fedora.efi,shimx64.efi,PreLoader.efi,\n" "# TextMode.efi,ebounce.efi,GraphicsConsole.efi,MokManager.efi,HashTool.efi,\n" "# HashTool-signed.efi,bootmgr.efi,fb{arch}.efi\n" "# (where \"{arch}\" is the architecture code, like \"x64\").\n" "# If you want to keep these defaults but add to them, be sure to\n" "# specify \"+\" as the first item in the new list; if you don't, then\n" "# items from the default list are likely to appear.\n" "#\n" "#dont_scan_files shim.efi,MokManager.efi\n\n" "# EFI NVRAM Boot#### variables that should NOT be presented as loaders\n" "# when \"firmware\" is an option to \"scanfor\". The comma-separated list\n" "# presented here contains strings that are matched against the\n" "# description field -- if a value here is a case-insensitive substring\n" "# of the boot option description, then it will be excluded from the\n" "# boot list. To specify a string that includes a space, enclose it\n" "# in quotes. Specifying \"shell\" will counteract the automatic\n" "# inclusion of built-in EFI shells.\n" "#\n" "#dont_scan_firmware HARDDISK,shell,\"Removable Device\"\n\n" "# Scan for Linux kernels that lack a \".efi\" filename extension. This is\n" "# useful for better integration with Linux distributions that provide\n" "# kernels with EFI stub loaders but that don't give those kernels filenames\n" "# that end in \".efi\", particularly if the kernels are stored on a\n" "# filesystem that the EFI can read. When set to \"1\", \"true\", or \"on\", this\n" "# option causes all files in scanned directories with names that begin with\n" "# \"vmlinuz\", \"bzImage\", or \"kernel\" to be included as loaders, even if they\n" "# lack \".efi\" extensions. Passing this option a \"0\", \"false\", or \"off\" value\n" "# causes kernels without \".efi\" extensions to NOT be scanned.\n" "# Default is \"true\" -- to scan for kernels without \".efi\" extensions.\n" "#\n" "scan_all_linux_kernels false\n\n" "# Combine all Linux kernels in a given directory into a single entry.\n" "# When so set, the kernel with the most recent time stamp will be launched\n" "# by default, and its filename will appear in the entry's description.\n" "# To launch other kernels, the user must press F2 or Insert; alternate\n" "# kernels then appear as options on the sub-menu.\n" "# Default is \"true\" -- kernels are \"folded\" into a single menu entry.\n" "#\n" "#fold_linux_kernels false\n\n" "# Comma-delimited list of strings to treat as if they were numbers for the\n" "# purpose of kernel version number detection. These strings are matched on a\n" "# first-found basis; that is, if you want to treat both \"linux-lts\" and\n" "# \"linux\" as version strings, they MUST be specified as \"linux-lts,linux\",\n" "# since if you specify it the other way, both vmlinuz-linux and\n" "# vmlinuz-linux-lts will return with \"linux\" as the \"version string,\" which\n" "# is not what you'd want. Also, if the kernel or initrd file includes both a\n" "# specified string and digits, the \"version string\" includes both. For\n" "# instance, \"vmlinuz-linux-4.8\" would yield a version string of \"linux-4.8\".\n" "# This option is intended for Arch and other distributions that don't include\n" "# version numbers in their kernel filenames, but may provide other uniquely\n" "# identifying strings for multiple kernels. If this feature causes problems\n" "# (say, if your kernel filename includes \"linux\" but the initrd filename\n" "# doesn't), be sure this is set to an empty string\n" "# (extra_kernel_version_strings \"\") or comment out the option to disable it.\n" "# Default is no extra version strings\n" "#\n" "#extra_kernel_version_strings linux-lts,linux\n\n" "# Write to systemd EFI variables (currently only LoaderDevicePartUUID) when\n" "# launching Linux via an EFI stub loader, ELILO, or GRUB. This variable,\n" "# when present, causes systemd to mount the ESP at /boot or /efi *IF* either\n" "# directory is empty and nothing else is mounted there.\n" "# Default is \"false\"\n" "#\n" "#write_systemd_vars true\n\n" "# Set the maximum number of tags that can be displayed on the screen at\n" "# any time. If more loaders are discovered than this value, rEFInd shows\n" "# a subset in a scrolling list. If this value is set too high for the\n" "# screen to handle, it's reduced to the value that the screen can manage.\n" "# If this value is set to 0 (the default), it's adjusted to the number\n" "# that the screen can handle.\n" "#\n" "#max_tags 0\n\n" "# Set the default menu selection. The available arguments match the\n" "# keyboard accelerators available within rEFInd. You may select the\n" "# default loader using:\n" "# - A digit between 1 and 9, in which case the Nth loader in the menu\n" "# will be the default.\n" "# - A \"+\" symbol at the start of the string, which refers to the most\n" "# recently booted loader.\n" "# - Any substring that corresponds to a portion of the loader's title\n" "# (usually the OS's name, boot loader's path, or a volume or\n" "# filesystem title).\n" "# You may also specify multiple selectors by separating them with commas\n" "# and enclosing the list in quotes. (The \"+\" option is only meaningful in\n" "# this context.)\n" "# If you follow the selector(s) with two times, in 24-hour format, the\n" "# default will apply only between those times. The times are in the\n" "# motherboard's time standard, whether that's UTC or local time, so if\n" "# you use UTC, you'll need to adjust this from local time manually.\n" "# Times may span midnight as in \"23:30 00:30\", which applies to 11:30 PM\n" "# to 12:30 AM. You may specify multiple default_selection lines, in which\n" "# case the last one to match takes precedence. Thus, you can set a main\n" "# option without a time followed by one or more that include times to\n" "# set different defaults for different times of day.\n" "# The default behavior is to boot the previously-booted OS.\n" "#\n" "default_selection 2\n" "#default_selection Microsoft\n" "#default_selection \"+,bzImage,vmlinuz\"\n" "#default_selection Maintenance 23:30 2:00\n" "#default_selection \"Maintenance,macOS\" 1:00 2:30\n\n" "# Enable VMX bit and lock the CPU MSR if unlocked.\n" "# On some Intel Apple computers, the firmware does not lock the MSR 0x3A.\n" "# The symptom on Windows is Hyper-V not working even if the CPU\n" "# meets the minimum requirements (HW assisted virtualization and SLAT)\n" "# DO NOT SET THIS EXCEPT ON INTEL CPUs THAT SUPPORT VMX! See\n" "# http://www.thomas-krenn.com/en/wiki/Activating_the_Intel_VT_Virtualization_Feature\n" "# for more on this subject.\n" "# The default is false: Don't try to enable and lock the MSR.\n" "#\n" "#enable_and_lock_vmx false\n\n" "# Tell a Mac's EFI that macOS is about to be launched, even when it's not.\n" "# This option causes some Macs to initialize their hardware differently than\n" "# when a third-party OS is launched normally. In some cases (particularly on\n" "# Macs with multiple video cards), using this option can cause hardware to\n" "# work that would not otherwise work. On the other hand, using this option\n" "# when it is not necessary can cause hardware (such as keyboards and mice) to\n" "# become inaccessible. Therefore, you should not enable this option if your\n" "# non-Apple OSes work correctly; enable it only if you have problems with\n" "# some hardware devices. When needed, a value of \"10.9\" usually works, but\n" "# you can experiment with other values. This feature has no effect on\n" "# non-Apple computers.\n" "# The default is inactive (no macOS spoofing is done).\n" "#\n" "#spoof_osx_version 10.9\n\n" "# Set the CSR values for Apple's System Integrity Protection (SIP) feature.\n" "# Values are two-byte (four-character) hexadecimal numbers. These values\n" "# define which specific security features are enabled. Below are the codes\n" "# for what the values mean. Add them up (in hexadecimal!) to set new values.\n" "# Apple's \"csrutil enable\" and \"csrutil disable\" commands set values of 10\n" "# and 877, respectively. (Prior to OS 11, 77 was used rather than 877; 877\n" "# is required for OS 11, and should work for OS X 10.x, too.)\n" "# CSR_ALLOW_UNTRUSTED_KEXTS 0x0001\n" "# CSR_ALLOW_UNRESTRICTED_FS 0x0002\n" "# CSR_ALLOW_TASK_FOR_PID 0x0004\n" "# CSR_ALLOW_KERNEL_DEBUGGER 0x0008\n" "# CSR_ALLOW_APPLE_INTERNAL 0x0010\n" "# CSR_ALLOW_UNRESTRICTED_DTRACE 0x0020\n" "# CSR_ALLOW_UNRESTRICTED_NVRAM 0x0040\n" "# CSR_ALLOW_DEVICE_CONFIGURATION 0x0080\n" "# CSR_ALLOW_ANY_RECOVERY_OS 0x0100\n" "# CSR_ALLOW_UNAPPROVED_KEXTS 0x0200\n" "# CSR_ALLOW_EXECUTABLE_POLICY_OVERRIDE 0x0400\n" "# CSR_ALLOW_UNAUTHENTICATED_ROOT 0x0800\n" "#csr_values 10,877\n\n" "# Include a secondary configuration file within this one. This secondary\n" "# file is loaded as if its options appeared at the point of the \"include\"\n" "# token itself, so if you want to override a setting in the main file,\n" "# the secondary file must be referenced AFTER the setting you want to\n" "# override. Note that the secondary file may NOT load a tertiary file.\n" "#\n" "#include manual.conf\n\n" "# Sample manual configuration stanzas. Each begins with the \"menuentry\"\n" "# keyword followed by a name that's to appear in the menu (use quotes\n" "# if you want the name to contain a space) and an open curly brace\n" "# (\"{\"). Each entry ends with a close curly brace (\"}\"). Common\n" "# keywords within each stanza include:\n" "#\n" "# volume - identifies the filesystem from which subsequent files\n" "# are loaded. You can specify the volume by filesystem\n" "# label, by partition label, or by partition GUID number\n" "# (but NOT yet by filesystem UUID number).\n" "# loader - identifies the boot loader file\n" "# initrd - Specifies an initial RAM disk file\n" "# icon - specifies a custom boot loader icon\n" "# ostype - OS type code to determine boot options available by\n" "# pressing Insert. Valid values are \"MacOS\", \"Linux\",\n" "# \"Windows\", and \"XOM\". Case-sensitive.\n" "# graphics - set to \"on\" to enable graphics-mode boot (useful\n" "# mainly for MacOS) or \"off\" for text-mode boot.\n" "# Default is auto-detected from loader filename.\n" "# options - sets options to be passed to the boot loader; use\n" "# quotes if more than one option should be passed or\n" "# if any options use characters that might be changed\n" "# by rEFInd parsing procedures (=, /, #, or tab).\n" "# disabled - use alone or set to \"yes\" to disable this entry.\n" "#\n" "# Note that you can use either DOS/Windows/EFI-style backslashes (\\)\n" "# or Unix-style forward slashes (/) as directory separators. Either\n" "# way, all file references are on the ESP from which rEFInd was\n" "# launched.\n" "# Use of quotes around parameters causes them to be interpreted as\n" "# one keyword, and for parsing of special characters (spaces, =, /,\n" "# and #) to be disabled. This is useful mainly with the \"options\"\n" "# keyword. Use of quotes around parameters that specify filenames is\n" "# permissible, but you must then use backslashes instead of slashes,\n" "# except when you must pass a forward slash to the loader, as when\n" "# passing a root= option to a Linux kernel.\n\n" "# Below are several sample boot stanzas. All are disabled by default.\n" "# Find one similar to what you need, copy it, remove the \"disabled\" line,\n" "# and adjust the entries to suit your needs.\n\n" "# A sample entry for a Linux 3.13 kernel with EFI boot stub support\n" "# on a partition with a GUID of 904404F8-B481-440C-A1E3-11A5A954E601.\n" "# This entry includes Linux-specific boot options and specification\n" "# of an initial RAM disk. Note uses of Linux-style forward slashes.\n" "# Also note that a leading slash is optional in file specifications.\n" "menuentry Linux {\n" " icon EFI/refind/icons/os_linux.png\n" " volume 904404F8-B481-440C-A1E3-11A5A954E601\n" " loader bzImage-3.3.0-rc7\n" " initrd initrd-3.3.0.img\n" " options \"ro root=UUID=5f96cafa-e0a7-4057-b18f-fa709db5b837\"\n" " disabled\n" "}\n\n" "# Below is a more complex Linux example, specifically for Arch Linux.\n" "# This example MUST be modified for your specific installation; if nothing\n" "# else, the PARTUUID code must be changed for your disk. Because Arch Linux\n" "# does not include version numbers in its kernel and initrd filenames, you\n" "# may need to use manual boot stanzas when using fallback initrds or\n" "# multiple kernels with Arch. This example is modified from one in the Arch\n" "# wiki page on rEFInd (https://wiki.archlinux.org/index.php/rEFInd).\n" "menuentry \"Arch Linux\" {\n" " icon /EFI/refind/icons/os_arch.png\n" " volume \"Arch Linux\"\n" " loader /boot/vmlinuz-linux\n" " initrd /boot/initramfs-linux.img\n" " options \"root=PARTUUID=5028fa50-0079-4c40-b240-abfaf28693ea rw add_efi_memmap\"\n" " submenuentry \"Boot using fallback initramfs\" {\n" " initrd /boot/initramfs-linux-fallback.img\n" " }\n" " submenuentry \"Boot to terminal\" {\n" " add_options \"systemd.unit=multi-user.target\"\n" " }\n" " disabled\n" "}\n\n" "# A sample entry for loading Ubuntu using its standard name for\n" "# its GRUB 2 boot loader. Note uses of Linux-style forward slashes\n" "menuentry Ubuntu {\n" " loader /EFI/ubuntu/grubx64.efi\n" " icon /EFI/refind/icons/os_linux.png\n" " disabled\n" "}\n\n" "# A minimal ELILO entry, which probably offers nothing that\n" "# auto-detection can't accomplish.\n" "menuentry \"ELILO\" {\n" " loader \\EFI\\elilo\\elilo.efi\n" " disabled\n" "}\n\n" "# Like the ELILO entry, this one offers nothing that auto-detection\n" "# can't do; but you might use it if you want to disable auto-detection\n" "# but still boot Windows....\n" "menuentry \"Windows 7\" {\n" " loader \\EFI\\Microsoft\\Boot\\bootmgfw.efi\n" " disabled\n" "}\n\n" "# EFI shells are programs just like boot loaders, and can be\n" "# launched in the same way. You can pass a shell the name of a\n" "# script that it's to run on the \"options\" line. The script\n" "# could initialize hardware and then launch an OS, or it could\n" "# do something entirely different.\n" "menuentry \"Windows via shell script\" {\n" " icon \\EFI\\refind\\icons\\os_win.png\n" " loader \\EFI\\tools\\shell.efi\n" " options \"fs0:\\EFI\\tools\\launch_windows.nsh\"\n" " disabled\n" "}\n\n" "# MacOS is normally detected and run automatically; however,\n" "# if you want to do something unusual, a manual boot stanza may\n" "# be the way to do it. This one does nothing very unusual, but\n" "# it may serve as a starting point. Note that you'll almost\n" "# certainly need to change the \"volume\" line for this example\n" "# to work.\n" "menuentry \"My macOS\" {\n" " icon \\EFI\\refind\\icons\\os_mac.png\n" " volume \"macOS boot\"\n" " loader \\System\\Library\\CoreServices\\boot.efi\n" " disabled\n" "}\n\n" "# The firmware_bootnum token takes a HEXADECIMAL value as an option\n" "# and sets that value using the EFI's BootNext variable and then\n" "# reboots the computer. This then causes a one-time boot of the\n" "# computer using this EFI boot option. It can be used for various\n" "# purposes, but one that's likely to interest some rEFInd users is\n" "# that some Macs with HiDPI displays produce lower-resolution\n" "# desktops when booted through rEFInd than when booted via Apple's\n" "# own boot manager. Booting using the firmware_bootnum option\n" "# produces the better resolution. Note that no loader option is\n" "# used in this type of configuration.\n" "menuentry \"macOS via BootNext\" {\n" " icon /EFI/refind/icons/os_mac.png\n" " firmware_bootnum 80\n" " disabled\n" "}\n\n" "menuentry \"System Rescue\" {\n" " icon /EFI/refind/next-theme/icons/os_rescue.png\n" " volume Extended_Boot_Loader\n" " loader /rescue/vmlinuz-linux-lts\n" " initrd /rescue/initramfs-linux-lts.img\n" " options \"root=LABEL=SafeGuard_Comet rootflags=noatime rw consoleblank=0 initrd=\\arch\\intel-ucode.img\"\n" " submenuentry \"Boot with fallback initramfs\" {\n" " initrd /initramfs-linux-lts-fallback.img\n" " }\n" " submenuentry \"Boot to CLI (no display manager)\" {\n" " add_options \"systemd.unit=multi-user.target\"\n" " }\n" " submenuentry \"Boot to systemd rescue.target\" {\n" " add_options \"systemd.unit=rescue.target\"\n" " }\n" "}\n\n" "menuentry \"Arch Linux\" {\n" " icon /EFI/refind/next-theme/icons/os_arch.png\n" " volume Extended_Boot_Loader\n" " loader /arch/vmlinuz-linux-zen\n" " initrd /arch/initramfs-linux-zen.img\n" " options \"zfs=comet/roots/arch rootflags=noatime rw quiet consoleblank=0 splash loglevel=3 rd.udev.log_priority=3 rd.systemd.show_status=auto vt.global_cursor_default=0 initrd=\\arch\\intel-ucode.img\"\n" " submenuentry \"No splash & verbose startup\" {\n" " options \"zfs=comet/roots/arch rootflags=noatime rw consoleblank=0 initrd=\\arch\\intel-ucode.img\"\n" " }\n" " submenuentry \"Boot with fallback InitRAMFS\" {\n" " initrd /arch/initramfs-linux-zen-fallback.img\n" " options \"zfs=comet/roots/arch rootflags=noatime rw consoleblank=0 initrd=\\arch\\intel-ucode.img\"\n" " }\n" " submenuentry \"Boot to CLI (no display manager)\" {\n" " options \"zfs=comet/roots/arch rootflags=noatime rw consoleblank=0 systemd.unit=multi-user.target initrd=\\arch\\intel-ucode.img\"\n" " }\n" " submenuentry \"Boot to systemd rescue.target\" {\n" " options \"zfs=comet/roots/arch rootflags=noatime rw consoleblank=0 systemd.unit=rescue.target initrd=\\arch\\intel-ucode.img\"\n" " }\n" "}\n\n" "menuentry \"Gentoo\" {\n" " icon /EFI/refind/next-theme/icons/os_gentoo.png\n" " volume Extended_Boot_Loader\n" " loader /gentoo/gent-zen.krn\n" " initrd /gentoo/genthost.ird\n" " options \"root=ZFS=comet/roots/gentoo rootflags=noatime rw quiet consoleblank=0 initrd=\\intel-ucode.img\"\n" " submenuentry \"Boot with fallback initramfs\" {\n" " initrd /gentfull.ird\n" " }\n" " submenuentry \"Boot to CLI (no display manager)\" {\n" " add_options \"systemd.unit=multi-user.target\"\n" " }\n" " submenuentry \"Boot to systemd rescue.target\" {\n" " add_options \"systemd.unit=rescue.target\"\n" " }\n" "}\n\n" "menuentry \"Windows 10\" {\n" " loader \\EFI\\Microsoft\\Boot\\bootmgfw.efi\n" "}\n\n" "include next-theme/theme.conf\n") matches = regex.finditer(test_str) for match_num, match in enumerate(matches, start=1): print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}") for group_num, group in enumerate(match.groups(), start=1): print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")

Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html