[Solved] split cell at first space
- mike.ritter
- Posts: 4
- Joined: Wed May 28, 2008 5:01 am
- Location: usa
[Solved] split cell at first space
How does one split a cell at the first space in Calc? Example: [filename my file description] to [filename] [my file description]. Merge/Split does not work. Data -> Text to Columns does not work. Perhaps I am looking for a formula that looks for the first instance of the [:space:] character using regular expressions as in a find and replace, but I do not know the proper function or syntax.
Last edited by mike.ritter on Wed May 28, 2008 7:34 am, edited 1 time in total.
Computers aren't just for geeks, but they sure make us look good.
Windows XP SP2 : OOo 2.4.0
6'2" 160lbs.
Peanut Butter and Jelly
Windows XP SP2 : OOo 2.4.0
6'2" 160lbs.
Peanut Butter and Jelly
Re: split cell at first space
"Does not work" could mean anything. Cell merging and splitting is about appearance rather than content. The text-to-columns should do the job.
Text in A1 and B assumed as first empty column:
B1: =SEARCH("[:space:]+";A1) One space at least. Due to a bug, regexes with a trailing named class [:somename:] fail. I use to add a quantifier such as +
C1: =MID(A1;B1;1)=" " Just a test if the found space is a plain " " (ascii-code 32). If not, it would explaing the failure of text-to-columns
D1: =LEFT(A1;B1-1) Left part before the space.
E1: =MID(A1;B1+1;LEN(A1)) Rest behind the space
Text in A1 and B assumed as first empty column:
B1: =SEARCH("[:space:]+";A1) One space at least. Due to a bug, regexes with a trailing named class [:somename:] fail. I use to add a quantifier such as +
C1: =MID(A1;B1;1)=" " Just a test if the found space is a plain " " (ascii-code 32). If not, it would explaing the failure of text-to-columns
D1: =LEFT(A1;B1-1) Left part before the space.
E1: =MID(A1;B1+1;LEN(A1)) Rest behind the space
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
- mike.ritter
- Posts: 4
- Joined: Wed May 28, 2008 5:01 am
- Location: usa
Re: split cell at first space
Villeroy, the code returned a null value (#VALUE) beginning in each cell.
Computers aren't just for geeks, but they sure make us look good.
Windows XP SP2 : OOo 2.4.0
6'2" 160lbs.
Peanut Butter and Jelly
Windows XP SP2 : OOo 2.4.0
6'2" 160lbs.
Peanut Butter and Jelly
Re: split cell at first space
Menu:Tools>Options...Calc>Calculation:[X]Enable regular expressions in formulas (this is off by default for all xls since Excel has no regexes)
If it still returns #VALUE then there is no space. Test: Type a space somewhere in the middle of the value.
If it still returns #VALUE then there is no space. Test: Type a space somewhere in the middle of the value.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
- mike.ritter
- Posts: 4
- Joined: Wed May 28, 2008 5:01 am
- Location: usa
Re: split cell at first space
Excellent! To wrap this up, for those who find the solution, if you want to use the information later copy the contents of D1 and E1 then "Paste Special" -> deselect all but "Text" into F1 and G1 respectively.
Computers aren't just for geeks, but they sure make us look good.
Windows XP SP2 : OOo 2.4.0
6'2" 160lbs.
Peanut Butter and Jelly
Windows XP SP2 : OOo 2.4.0
6'2" 160lbs.
Peanut Butter and Jelly