in reply to regex basics
I suggest this:
#!/usr/bin/perl while(<>) { next if /;{2,}/; next if /;\s{1}/; print unless /^\n/; } __END__ strip_ini.pl php.ini [PHP] ;user_ini.filename = ".user.ini" ;user_ini.filename = ;user_ini.cache_ttl = 300 engine = On short_open_tag = Off asp_tags = Off precision = 14 y2k_compliance = On output_buffering = 4096 ;output_handler = zlib.output_compression = Off ;zlib.output_compression_level = -1 ...about 300 lines more
Usage: strip_ini.pl php.ini > php.stripped.ini
Note:
The print unless /^\n/ prevents unwanted printing of emtpy lines. I don't know for the moment why they are there...;;;;;;;;;;;;;;;;;;; <-- the first next skips the ASCI art ; About php.ini ; <-- the second next skips the explanations ;;;;;;;;;;;;;;;;;;;
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex basics
by Anonymous Monk on Feb 04, 2015 at 07:44 UTC |