Capture

Updated: 09/07/2019 by Computer Hope

Capture may refer to any of the following:

1. In computing, the term capture refers to the process of obtaining information and putting it onto a storage device for future reference. For example, when highlighted text is cut or copied, it's captured and placed in the clipboard, allowing the user to paste the information elsewhere.

2. With computer programming and regular expressions, capture describes the process of grabbing matched text in parentheses in a regular expression and store it in a variable.

For example, in the below Perl code, the regular expression /([0-9]+)/ captures the first set of numbers it encounters going left to right in the $value variable.

my $value = "Nathan's number is 801-555-1234.";
if ($value =~ /([0-9]+)/) { print "Found area code: $1"; }

In the above example, it would return "Found area code: 801" when running the script, because it's the first found numbers found before running into a non-number (hyphen). Capturing text like this can be a great way of grabbing and storing only the text you want in a variable.

$1, Copy, Cut, Paste, Programming terms, Software terms