How to extract only part of the text which is extracted using CSS selector from a website

Hi @scott ,

Can you please help me create a snippet to extract only a specific part of the text extracted using text function under website function?

Example:
{site: text; page=https://test.com/*; select=ifneeded; selector=:nth-child(19) .fzqMMl}

Basically, I created a snippet which extracts data from a website from a specific field.

for eg: I am getting the result as Greeting from John P Surmai

I only want the name that is after Greeting from

my result should be: John P Surmai

Hi @Shairaz_Khan and welcome to the forum.
Try using regex.
Replace text with your selector

{text="Greeting from John P Surmai"}
{=extractregex(text,"Greeting from (.*)")}

Hi @Dan_Barak1

Firstly, thank you so much for your reply and creating this awesome tool. For some reason, this was not working for me. While I was going through the community, I got this solution, which is slightly different from yours. Instead of using *, I used + and it worked for me.

{=extractregex(text,"Greeting from (.+)")}

@Dan_Barak1 Could you also help me with one more issue please

Using site selector method I am extracting a value in currency which is in negative format.

for eg after extracting I am getting -345.00 GBP but I don't want that (-) sign in front of my value.

I just want 345.00 GBP

please help.

The same method worked for this as well. Thank you.

Hi @Dan_Barak1

The above snippet works great for me.

Can you please help to extract only the first name, instead of the full name after Greeting from.

For example, Greeting from John P Surmai, I just want to extract first name i.e "John"

Thank you for the help

Hey @Shairaz_Khan
Try this:

{text="Greeting from John P Surmai"}
{=extractregex(text,"Greeting from (\w*)")}

\w stands for a word character and doesn't include spaces.

1 Like