Regex match space in perl

I am trying to match

Begin_Page {Some Number}

while trying to avoid

Begin_Page_{Some Number}

I tried

$line =~ m/^Begin_Page\s/

but I noticed it sometimes does not match anything file while surely had Begin_Page 8703

Answers


Your regexp is correct; the line should match:

while (<DATA>) {
    if (/^Begin_Page\s/) { print "OK: " }
    else                 { print "KO: " }
    print;
}
__DATA__
test
1233
Begin_Page 123
Begin_Page_456
Begin_Page 8703

Output:

KO: test
KO: 1233
OK: Begin_Page 123
KO: Begin_Page_456
OK: Begin_Page 8703

Need Your Help

403 redirect doesn't work

.htaccess http-status-code-403

How to force apache to redirect to a 403 error?

C++ linked list doesn stop growing

c++ list pointers

I'm trying to write a function that calculates the N-th Fibonacci number using doubly linked lists, but for some reason when I compile and run the linked list does not stop growing, it keeps adding 1

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.