Split text by symbol: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
[[Category:Programming]] | [[Category:Programming]] | ||
[[Category:Data Science]] | |||
Revision as of 11:12, 18 April 2015
Split text by symbol (delimiter / separator)
Approachs
- Excel: (1) LEFT, RIGHT, FIND, LEN (2) MOD, FIND, LEN
- PHP: explode
- MySQL: 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 ):
SELECT TRIM(SUBSTRING_INDEX('25.040215, 121.512532' ,',', 1)) - How to get the second string ( 121.512532 ):
SELECT TRIM(SUBSTRING_INDEX('25.040215, 121.512532' ,',', -1))