http://www.perlmonks.org?node_id=1028423


in reply to regular expression for getting text between 1. and 2.

In the cases you've shown, there's whitespace enclosing the text you want, so you can use a lookbehind and lookahead to capaure the enclosed text:

use warnings; use strict; while (<DATA>) { print "$1\n" if /(?<=\s)([a-z\s]+)(?=\s)/i; } __DATA__ 1) some text 2) 1. some text 2. 1) some text 2. 1. 2.10.10.20 some text 2. 1) 2.10.10.20 2)

Output:

some text some text some text some text

Hope this helps!