regex - simple Perl regular expression -


hi i'm quite new perl , seeking parse simple line of code.

what need parse in of

#include "filename" 

i need regular expression file name.

i know there's split method in python this, don't know if there's similar func in perl

thanks

you could split in perl:

my $fn = (split('"', $include_line))[1]; 

...but that's pretty obtuse way of going it. i'd opt for

my ($fn) = $line =~ /^#include +"([^"]+)"/; 

instead, clearer , has advantage of returning nothing on non-#include lines rather returning false positives if input file contains other lines double-quoted text.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -