Search notes:

Perl regular expressions: match between

The following example matches the texts between <ITEMS> and </ITEMS>
#!/usr/bin/perl
use warnings;
use strict;

my $text = 'abc <ITEMS>de fghi</ITEMS> j kl mno <ITEMS>pq r stu vw</ITEMS> xyz';

my @items = $text =~ m,<ITEMS>((?:(?!<ITEMS>).)*?)</ITEMS>,g;

print join "\n", @items;
#
# de fghi
# pq r stu vw
Github repository about-perl, path: /regular-expressions/match-between-1.pl
Apparently, this construct is also known as tempered greedy token (also this Stackoverflow answer).

See also

Perl regular expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201476, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/regular-expressions/match-between(52): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78