‏إظهار الرسائل ذات التسميات string. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات string. إظهار كافة الرسائل

الثلاثاء، 24 ديسمبر 2013

Detect if a string consists of a substring of a string

You can split the strings into two arrays

a = "sun is clear".splitb = "sun cloud rain".split

and compute the intersection

a & b# => ["sun"] (a & b).empty?# => false

If the intersection is not empty, then they share pieces. Otherwise, you can also compute the difference of a - b

(a - b).size == a.size# => false

View the original article here

الجمعة، 20 ديسمبر 2013

Return same row multiple times if search string matches with 2 columns - Mysql

I'm trying to display the result from the following table

id | string1 | string2 1 | mysql | php 2 | mysql | mysql 3 | python | java

If I search the string 'mysql' in the table from column string1 and string2, I would like to get results as

1 mysql 2 mysql 2 mysql

Row id 2 should display multiple times as 'mysql' is presents in 2 columns(string1 and string2).

Is there any feasiblity to list like above results.

Note : I dont want to use UNION all

Thanks


View the original article here

How to replace only IP in url string in file

You will first need to read the files content. Then you could use a regular expression that matches the ip address (e.g. \d+\.\d+\.\d+\.\d+) and replace it with the new one. When you've done that write it back in the file again.

Here is a regex tester: http://www.regexplanet.com/advanced/java/index.html

Here a tutorial of how to read and write files: http://www.java-samples.com/showtutorial.php?tutorialid=392


View the original article here