text-manipulation

Using str_word_count for UTF8 texts

喜你入骨 提交于 2019-11-28 01:50:14
I have this text: $text = "Başka, küskün otomobil kaçtı buraya küskün otomobil neden kaçtı kaçtı buraya, oraya KISMEN @here #there J.J.Johanson hep. Danny:Where is mom? I don't know! Café est weiß for 2 €uros. My 2nd nickname is mike18."; Recently I was using this. $a1= array_count_values(str_word_count($text, 1, 'ÇçÖöŞşİIıĞğÜü@#é߀1234567890')); arsort($a1); You can check with this fiddle: http://ideone.com/oVUGYa But this solution doesn't solve all UTF8 problems. I can't write whole UTF8 set into str_word_count as parameter. So I created this: $wordsArray = explode(" ",$text); foreach (

Insert text on the current place of the cursor in the browser

白昼怎懂夜的黑 提交于 2019-11-27 14:16:38
问题 I have a modal window which helps formatting text. I have multiple textareas on the window. The modal should not be attached to a specific textarea, so when I press an Icon in the modal window, I need to insert a string/emoticon etc where-ever the cursor is currently. My question, How do I know in which element (textarea/input/whatever) the cursor is currently in? 回答1: The latest version of all browsers support document.activeElement. That will tell you which field currently has focus within

How to find words from one file in another file?

限于喜欢 提交于 2019-11-27 07:43:28
问题 In one text file, I have 150 words. I have another text file, which has about 100,000 lines. How can I check for each of the words belonging to the first file whether it is in the second or not? I thought about using grep , but I could not find out how to use it to read each of the words in the original text. Is there any way to do this using awk ? Or another solution? I tried with this shell script, but it matches almost every line: #!/usr/bin/env sh cat words.txt | while read line; do if

Using str_word_count for UTF8 texts

余生颓废 提交于 2019-11-27 04:50:52
问题 I have this text: $text = "Başka, küskün otomobil kaçtı buraya küskün otomobil neden kaçtı kaçtı buraya, oraya KISMEN @here #there J.J.Johanson hep. Danny:Where is mom? I don't know! Café est weiß for 2 €uros. My 2nd nickname is mike18."; Recently I was using this. $a1= array_count_values(str_word_count($text, 1, 'ÇçÖöŞşİIıĞğÜü@#é߀1234567890')); arsort($a1); You can check with this fiddle: http://ideone.com/oVUGYa But this solution doesn't solve all UTF8 problems. I can't write whole UTF8

How to extract two consecutive digits from a text field in MySQL?

落爺英雄遲暮 提交于 2019-11-26 03:34:36
问题 I have a MySQL database and I have a query as: SELECT `id`, `originaltext` FROM `source` WHERE `originaltext` regexp \'[0-9][0-9]\' This detects all originaltexts which have numbers with 2 digits in it. I need MySQL to return those numbers as a field , so i can manipulate them further. Ideally, if I can add additional criteria that is should be > 20 would be great, but i can do that separately as well. 回答1: If you want more regular expression power in your database, you can consider using LIB