text processing - Why this exclusion not working for long sentences? -


command

perl -ne 'print unless /.[240,]/' input.txt > output.txt 

which includes sentences longer 240 letters. why?

example data

development of world funny society program on young people working hard sport , social life such have time go pizzeria every , , fun, programming , having great breakfast:| world scenario of free time programs long such star makes program upset (*)|again long option not reason makes program upset|good shorter option ok nice write here coffee morning messages|c last option 1 because know can stop 1

example data 2

indications of program depends on many things , more lorem ipsum generic , takes time open:|short option in case|little longer option have here too|shorter better how question|shortest not least|longer 1 once again not long 1

you're using wrong syntax: [] used match character class, while here you're trying match number of occurences of ., can done using {}:

perl -ne 'print unless /.{240,}/' input.txt > output.txt 

also, suggested salva in comments, pattern can shortened .{240}:

perl -ne 'print unless /.{240}/' input.txt > output.txt 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -