Deleting words after space

Helo there,

I'm now around here and I'm looking for a way to use Selector tool and deleting everything after the first word on a Snippet,

Allow me to explain myself.

I got the following code when I selected the text {site: text; selector=.csstogettheinfo}

on the .csstogettheinfo I am referring to the tag used on the CSS code, for the HTML part it is inside a div.

The text I get contains the full name of a person so I get the full text I only want the name (first word) so I am wondering if there is a way to get the first word only and delete the rest for example.

The code looks like that and with the selector tool I picked the css code to refer to the exact part.

HTML code: <div class=''csstogettheinfo">john doe

CSS: .csstogettheinfo

The result I want to get is only the word "John"

If possible capitalize the first letter

The snippet is something like:

/**

Hello {site: text; selector=.csstogettheinfo} !

How are you?

**/

I am getting

/**

Hello john doe !

How are you?

**/

I want to get

/**

Hello John!

How are you?

**/

I truly appreciate your help.

Hi @Francisco_Alejandro , welcome to the forum!

You can use the string split function. For example,

{name="John Doe"}
{firstname=split(name, " ")[1]}
Hello {=firstname}!

Replace name above with the string that you got from the selector tool. Let me know if that works for you!

Hello Guang,

Thank you for your reponse, let me show you the HTML CODE where the name is looks like this

<div class="andes-tooltip__trigger" aria-expanded="false">John Doe</div>

Then when I use the string selector I get

.andes-tooltip__trigger"

type or paste code here


I tested it and I get


Hello .hook-form_tooltip!

It seems to not be working

Any suggestion I could try?

Does this work for you?

{name={site: text; selector=.andes-tooltip__trigger}}
{firstname=split(name, " ")[1]}
Hello {=firstname}!

1 Like

Hello,

I am going to test it but it looks like it got it to work using

{=split({site: text; selector=.hook-form_tooltip}, " ")[1]}

but I must ask, I know it's too much but any way to get the first letter as uppercase?

Sorry to ask too much.

Thanks in advance.

No worries, Francisco. I am happy to help.

{=split(proper({site: text; selector=.hook-form_tooltip}), " ")[1]}

Here I have used proper which is a string function.

1 Like

I want to thank you for your kind help

It is working as expected.

Have a great night/day

2 Likes