[Solved] String manipulation trial using functions

Discuss the spreadsheet application
Locked
User avatar
Nicholas59
Banned
Posts: 26
Joined: Sat Oct 12, 2024 1:15 pm

[Solved] String manipulation trial using functions

Post by Nicholas59 »

Good Morning,

I was wondering whether it would have been possible peeking simple words in a cell to rearrange them in plain text.
For this reason, i have attached a "french cuisine" simple spreadsheet.
Your comments would be really appreciated.
Regards
Attachments
transposition texte.ods
(10.54 KiB) Downloaded 18 times
Last edited by MrProgrammer on Tue Nov 12, 2024 4:47 pm, edited 2 times in total.
Reason: Lock topic from banned user
Libre Office 7.3.7 on Ubuntu 22.04
User avatar
karolus
Volunteer
Posts: 1199
Joined: Sat Jul 02, 2011 9:47 am

Re: String manipulation trial using functions

Post by karolus »

Libreoffice:

Code: Select all

=REGEX(C3;"^(\w+)\b.*?\b(\w+)$";"$2 de $1")
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 24.8… flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
User avatar
Nicholas59
Banned
Posts: 26
Joined: Sat Oct 12, 2024 1:15 pm

Re: String manipulation trial using functions

Post by Nicholas59 »

I beg your pardon, karolus, but it seems there are troubles with brackets. (Error #NAME).

Could however be the fact that my version is 7.3.7...

Thanks
Libre Office 7.3.7 on Ubuntu 22.04
User avatar
robleyd
Moderator
Posts: 5265
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: String manipulation trial using functions

Post by robleyd »

#NAME error has nothing to do with brackets.
525 #NAME?

Invalid names

An identifier could not be evaluated, for example, no valid reference, no valid function name, no column/row label, no macro, incorrect decimal separator, add-in not found.
See column I in the attached file where Karolus' formula functions as expected.
REGEX function was introduced in LO 6.2

Of course this is a specific solution for a specific case as per your sample. Doubtless your real life situation will be more varied; in which case you'll need to provide more detail on exactly what you are trying to achieve.
Attachments
transposition2.ods
(12.49 KiB) Downloaded 13 times
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue
Unexpected '{' on line 32
.
User avatar
karolus
Volunteer
Posts: 1199
Joined: Sat Jul 02, 2011 9:47 am

Re: String manipulation trial using functions

Post by karolus »

Nicholas59 wrote: Sun Oct 27, 2024 11:04 am I beg your pardon, karolus, but it seems there are troubles with brackets. (Error #NAME).
I would guess you have trouble wth copy & paste, so far I can see the localized Function-name for »REGEX« is in french also »REGEX« !!

btw. it seems the topic is inspired by https://ask.libreoffice.org/t/tableau-d ... ion/112848
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 24.8… flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
User avatar
Nicholas59
Banned
Posts: 26
Joined: Sat Oct 12, 2024 1:15 pm

Re: String manipulation trial using functions

Post by Nicholas59 »

Thank you karolus and robleyd. You help was precious. REGEX in italian would be ESPR.REG().
Libre Office 7.3.7 on Ubuntu 22.04
User avatar
Lupp
Volunteer
Posts: 3620
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved]String manipulation trial using functions

Post by Lupp »

Possibly even a bit simpler and easier to understand:

Code: Select all

=REGEX(C3;"(.*), (.*)";"$2 de $1";1)
for the first example.
On Windows 10: LibreOffice 24.8.3 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Nicholas59
Banned
Posts: 26
Joined: Sat Oct 12, 2024 1:15 pm

Re: [Solved]String manipulation trial using functions

Post by Nicholas59 »

Bedanke mich, Lupp. Das war sehr nett.
Libre Office 7.3.7 on Ubuntu 22.04
Locked