14,954
edits
(Created page with "Split text by symbol (delimiter / separator) Approachs * Excel: (1) LEFT, RIGHT, FIND, LEN (2) MOD, FIND, LEN * PHP: explode * MySQL: [http://www.w3resource.com/mysql/string-...") |
No edit summary |
||
| Line 1: | Line 1: | ||
Split text by symbol (delimiter / separator) | Split text by symbol (delimiter / separator) | ||
Approachs | == Approachs == | ||
* Excel: (1) LEFT, RIGHT, FIND, LEN (2) MOD, FIND, LEN | * Excel: (1) LEFT, RIGHT, FIND, LEN (2) MOD, FIND, LEN | ||
* PHP: explode | * PHP: explode | ||
* MySQL: [http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php MySQL SUBSTRING_INDEX() function - w3resource] | * MySQL: [http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php MySQL SUBSTRING_INDEX() function - w3resource] | ||
== Example == | |||
Task: Split 25.040215, 121.512532 by the comma ( , ) | |||
Expected output: | |||
* 25.040215 | |||
* 121.512532 | |||
MySQL Approach | |||
# How to get the first string ( 25.040215 ): {{code | code=SELECT TRIM(SUBSTRING_INDEX('25.040215, 121.512532' ,',', <span style="color:red">1</span>))}} | |||
# How to get the second string ( 121.512532 ): {{code | code=SELECT TRIM(SUBSTRING_INDEX('25.040215, 121.512532' ,',', <span style="color:red">-1</span>))}} | |||
[[Category:Programming]] | [[Category:Programming]] | ||