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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -