skip to content
Alvin Lucillo

Capture group

/ 1 min read

💻 Tech

To extract information from text, you use a match/capture group with parentheses.

Regex: ^(.*).(img|png)$ This searches for line with one or more characters followed by a dot and image file extensions. If there is a match, the capture groups () will capture the file names and file extensions.

test1.img      -- captures test1 and img
test2.img.bak
test3.png      -- captures test3 and png
test4.txt