Perl regex with pipes -


i'm not perl monk, if me digest regex(if one) do?

my $pathhere = "/some/path/to/file"; $paththere = "/some/path/"; $pathhere =~ s|$paththere||; 

perl not everyday tool, quite shy on knowledge - guess subs match var value, guessing not way go - pipes throw me off...

thanks

in perl you'd use / delimiter in regexp.

$pathhere =~ s/abc/def/;   # replace 'abc' 'def' 

however can see paths, that's problematic, since you'd have escape everything.

$pathhere =~ s/my\/path\/here/my\/newpath\/there/;   

consequently perl allows specify different delimiter character after 's', hence:

$pathhere =~ s|my/path/here|my/newpath/there|; 

see the documentation more information.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -