#!/usr/bin/perl use warnings; use strict; use 5.010; my $string = 'SRC=array.c builtin.c \ missing.c msg.c'; #Regex-1 Following matches, but WHY? String has a single space between "builtin.c \" $string =~ m/^\w+=[^\n\\]*\\/; #Regex-2 Following also matches $string =~ m/^\w+=[^\n\\]* \\/; #pay attention to single space between * and \ #Regex-3 Following does NOT match $string =~ m/^\w+=[^\n\\]* \\/; #pay attention to double spaces between * and \ say $string;