Answer the question
In order to leave comments, you need to log in
Sample from the database (rows)
How to select from a table all strings:
1) consisting of more than 7 words
2) containing only characters from 'a' to 'z', from 'a' to 'z', numbers and the sign '-'
Answer the question
In order to leave comments, you need to log in
1. containing 6 or more word separators
2. possibly regular expressions
postgresmen.ru/articles/view/33
and further to the original documentation
www.postgresql.org/docs/8.3/static/functions-matching.html
1) SELECT * FROM "public".words WHERE key_word !~* '[0-9a-za...i]\-\r\n\20' LIMIT 10
Finds everything, including the necessary and unnecessary.
2) Search for 6 delimiters (spaces): SELECT * FROM "public".words WHERE key_word ~* '\20{6,}' LIMIT 10
Doesn't work at all (looks for consecutive spaces?)
Or hardcode: (any_characters)(separators)(any_characters)(separators)(any_characters)(separators)(any_characters)(separators)(any_characters)(separators)(any_characters) as a large regular expression. Or something trickier, like: ((any_characters)(separators)){6}
1) consisting of more than 7 words
select *
from (select str,replace(replace(replace(str,' ','~ '),' ~',''),'~','') sstr from t) s
where length(sstr)-length(replace(sstr,' ','')) +1 > 7
Регекспами:
select * from t where ' '||str ~ '(\s+\S+){8,}'
2) содержащих только символы от 'a' до 'z', от 'а' до 'я', цифры и знак '-'
select * from t where str ~ '^[-\w\dа-я]+$'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question