Extract any string after colon in Google sheet cell with multiple lines - google-sheets

I am trying to extract everything after a colon : in a cell that has multiple lines within one cell.
Any text: John
Any text: Peter
Any text: Paul
Expected result
John
Peter
Paul
Any help, would be appreciated.
Tried
=REGEXEXTRACT(A1,".*:(.*)")
But only returning first line

use:
=ARRAYFORMULA(IFERROR(BYROW(SPLIT(A:A,char(10)),LAMBDA(ax,JOIN(CHAR(10),REGEXEXTRACT(ax,":\s?(.*)$"))))))

You can use this:
=INDEX(REGEXEXTRACT(split(A1,CHAR(10)),".+: (.+)"))
Or, if you want it vertically, add TRANSPOSE:
=TRANSPOSE(INDEX(REGEXEXTRACT(split(A1,CHAR(10)),".+: (.+)")))

Related

Is there a way to flip four namest?

I'm trying to put the last name and "," ahead of the first name and succeeding names.
I've managed to get it up to 3 names but now I have to account if the person has 4 names in their whole name. Mainly using this for Google Sheets.
Here's what I use for the 3 names.
=MID(TRIM(A2)&", "&TRIM(A2),IF(LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))=1,FIND(" ",TRIM(A2))+1,FIND(" ",TRIM(A2),FIND(" ",TRIM(A2))+1)+1),LEN(TRIM(A2))+1)
so that turns "John Doe Smith" into "Smith, John Doe"
Anyone can help to account for 4 names?
Use regexreplace(), like this:
=regexreplace(A2, "(.*) (\w+)", "$2, $1")
To learn the exact regular expression syntax used by Google Sheets, see RE2.
Use
=REGEXREPLACE(A2,"(\w+ \w+) (\w+)","$2, $1")
=REGEXREPLACE(A2,"(.*)\s(.*?)$","$2, $1")

Splitting Text and Formatting it - Google Sheets

I have a log file with three fields, the first two are userIDs and the third is an item description. Can I use a single formula to Split the text, format the first 2 items, and leave the 3rd alone?
Sample Data:
<#!9812391203019>; <#!98120319283> ; Short Description
Formula Currently used:
=ARRAYFORMULA(REGEXEXTRACT(TRIM(SPLIT(A3,";")),"[0-9]+"))
This works to extract the userID from the unneeded in the first two columns but will only give me numbers for the third.
Previous Formula was within the REGEXEXTRACT but it left the unneeded "<#!" and ">" in the columns which I wanted to remove.
Any help and suggestions would be appreciated! Thanks in advance!
Does this work?
=Split(RegexReplace(A1,"[<#!>]",),"; ",0)
try:
=INDEX(IFERROR(REGEXREPLACE(TRIM(SPLIT(A1:A5, ";")), "[#!<>]", )))

How to extract text from string?

I want to extract 2 from the string in cell C3 and return it as the result of the function in cell E3:
Probably SPLIT is the wrong approach here.
Edit:
I replaced the 2 with s because some approaches work for numbers but not for letters:
Try the following
=REGEXEXTRACT(A1,"\d")*1
Following OP's edit
=REGEXEXTRACT(A2,";(.*),")
Please read more about REGEXEXTRACT

Compare two lists, then add missing data to the bottom of one list?

I have been searching and searching and I've tried a dozen different things, and the array formula that added 50,000 rows to my sheet (I didn't even know that was possible...) and crashed my browser was the final straw. So I'm asking for help...
Basically, I have a static list of names in sheet1(Grades) that are sorted alphabetically. I have an importrange in sheet2(Data) with another list of names, not sorted alphabetically (And it cannot be sorted alphabetically.) Something like this:
Grades:
Bill
Charlie
Fred
George
Percy
Ron
and
Data:
Ron
Bill
Fred
Percy
Harry
Hermione
Molly
Arthur
What I need is to imput a formula in the cell below the last name on sheet1(Grades) that checks all of the names above that cell, compares them to the names on sheet2(Data), and returns the first name that's missing. For example:
Grades:
Bill
Charlie
Fred
George
Percy
Ron
(Formula Here) = Harry
(Formula Here) = Hermione
Etc.
The New names should always be at the bottom of the Data list, if that help any.
Here's a link to a copy of the spreadsheet.
Hope I got the permissions correct... Most of it was protected, but I think it should be open for edits now. Any help would be much appreciated. I really didn't think I was trying to do something that difficult, lol.
So I take it you want basically the difference between two lists. I've put this formula in the cell below the last entry in column B in Grades, hope this is what you want:
=filter(Data!A1:A40, iserror(match(Data!A1:A40, B5:B45, 0)))

Strange value from ImportXML

I use the following importXML:
=IMPORTXML("http://www.morningstar.se/guide/quicktake?id=0P00009NT9"; "/html/body/div[2]/div/div[1]/div/div[4]/div[1]/div[3]/table[1]/tbody/tr[1]/td[2]")
to scrape text into my cell and two cells across the row where I get the latest GAV: 116,17 SEK.
I would like to use that number value. I have tried with =LEFT(A3;3) but that only gives an error.
How might I retrieve it?
I don't know if 'SEK' is always going to be at the end of the string, but for your present example see if this works:
=ArrayFormula(REGEXEXTRACT(JOIN(" "; IMPORTXML("http://www.morningstar.se/guide/quicktake?id=0P00009NT9"; "/html/body/div[2]/div/div[1]/div/div[4]/div[1]/div[3]/table[1]/tbody/tr[1]/td[2]")); {"^(.+)\s\d"\ "([0-9,]+)"}))
If you only need the number and not the preceding text:
=ArrayFormula(REGEXEXTRACT(JOIN(" "; IMPORTXML("http://www.morningstar.se/guide/quicktake?id=0P00009NT9"; "/html/body/div[2]/div/div[1]/div/div[4]/div[1]/div[3]/table[1]/tbody/tr[1]/td[2]")); "([0-9,]+)"))+0
You might wrap your formula in:
1*substitute(index( <your formula> ;3);" SEK";"")

Resources