#!/usr/bin/perl -w use strict; my $mystring = 'ABCblahblahDEF'; if ( $mystring =~ /(.*?)<\/ID>/) { my $ID = $1; print "$ID\n"; }