Extract Required Data from the Cell Through Formula - regex

I have been using below formula which extract the desired result from the cell but now i am trying to get more data from the cell and i have tried at my end to get further values from the cell but its not working.
I have attached a Google Sheet where data and desired result is available and as well my fomrula.
any help will be appreciated.
=ArrayFormula(IFERROR(IFERROR(REGEXEXTRACT(A3:A,".* (COMPLETE) .*"),REGEXEXTRACT(A3:A,"^\*\*\* (.* )? "))))
https://docs.google.com/spreadsheets/d/1WjpvEfpndRJ-tTOF99mSF9knMyF5Sq_FVpxnnvbgHHg/edit?usp=sharing

Your solution is a similar formula
=ArrayFormula(TRIM(REGEXREPLACE(A3:A,"\.\.\.(.*)|\*\*\*","")))
You use TRIM only to reject empty spaces from beginning or end of result.
The formula keeps only everything between *** and ...

Related

Regular Expression - Extract Words and number

So I'm using Regexextract in GoogleSheet to find the value for a big amount of data. I have 2 problems I don't know to extract or what I did wrong. Feel free to point out my mistakes and help me with a solution.
Require: I need to extract the part number which format is ABCD#### or ABCD-#### which is is Upper character and numbers follow after, with or w/o "-" , for example KTA1763 or SPD-4124
# I use this formula: =Regexextract(A1,"([A-Z]+-?[0-9]*)") .FYI, the values I'm extracting, it could appear either at the beginning, middle or last.
1.First problem, I have the value as below:
REACH TECH 223/224 list document for KTD2026BEWE-TR
=> Extract result : REACH
[What I need: KTD2026]
2.I have the value as:
information for Part number KTA1550EDS-TR
=> Extract result: P
[What I need: KTA1550]
Please let me know which part in the formula should I fix to have the final expected result. Or how should I alter my formula for that matter, big thanks
go for:
=INDEX(IFNA(REGEXEXTRACT(A1:A, "[A-Z]+\d+")))
Try this in one cell.
=ArrayFormula(IF(A2:A="",,REGEXEXTRACT(REGEXEXTRACT(A2:A, ".+"&REGEXEXTRACT(A2:A, "[0-9]+")), ".+\s(.+)")))

How to filter by Regex in LibreOffice?

I've got this string:
{"success":true,"lowest_price":"1,49€","volume":"1,132","median_price":"1,49€"}
Now I want the value for median_price being displayed in a cell. HHow can I achive this with Regex?
With regex101.com I've came to this solution:
(?<=median_price":")\d{0,4},\d{2}€
But this one does not seem to be working in LibreOffice calc.
I'd advise to discard the Euro-symbol at first since you'd probably want to retrieve a value to calculate with, a numeric value. Therefor try:
Formula in B1:
=--REGEX(A1;".*median_price"":""(\d+(?:,\d+)?)€.*";"$1")
The double unary will transform the result from the 1st capture group into a number. I then went ahead and formatted the cell to display currency (Ctrl+Shift+4).
Note: I went with a slightly different regular pattern. But go with whatever works for your data I supppose.

How can I extract specific patterns from a string?

I currently have a dataset filled with the following pattern:
My goal is to get each value into a different cell.
I have tried with the following formula, but it's not yielded the results I am looking for.
=SPLIT(D8,"[Stock]",FALSE,FALSE)
I would appreciate any guidance on how I can get to the ideal output, using Google Sheets.
Thank you in advance!
I will assume here from your post that your original data runs D8:D.
If you want to retain [Stock] in each entry, try the following in the Row-8 cell of a column that is otherwise empty from Row 8 downward:
=ArrayFormula(IF(D8:D="",,TRIM(SPLIT(REGEXREPLACE(D8:D&"~","(\[Stock\]).","$1~"),"~",1,1))))
If you don't want to retain [Stock] in each entry, use this version:
=ArrayFormula(IF(D8:D="",,TRIM(SPLIT(REGEXREPLACE(D8:D&"~","\[Stock\].","~"),"~",1,1))))
These formulas don't function based on using any punctuation at all as markers. They also assure that you don't wind up with blank (and therefore unusable) cells interspersed for ending SPLITs.
, only used in the separator
=ARRAYFORMULA(SPLIT(D8:D,", ",FALSE))
, used also in each string ([stock] will be replaced)
=ARRAYFORMULA(SPLIT(D8:D," [Stock], ",FALSE))
, used also in each string ([stock] will not be replaced)
=ArrayFormula(SPLIT(REGEXREPLACE(M9:M11,"(\[Stock\]), ","$1♦"),"♦"))
use:
=INDEX(TRIM(IFNA(SPLIT(D8:D; ","))))

Google Sheets regexextract multiple text strings from a cell

I am trying to extract the hashtag info from a twitter data cell in google sheets.
We can call this Cell A1:
[{"text":"QOTD","indices":[13,18]},{"text":"CSEC4CG","indices":[87,95]},{"text":"myCSEC","indices":[96,103]},{"text":"Connecticut","indices":[104,116]},{"text":"GiveBack","indices":[117,126]},{"text":"COVID19","indices":[127,135]}]
In a perfect situation I would be able to produce this in another cell extracted from A1:
#QOTD #CSEC4CG #myCSEC #Connecticut #Giveback #COVID19
I am lost how to do it using REGEXTRACT. I assume this is the best method, but any that gets the job done is good.
Thank you for any help!
You want to achieve the following conversion using the built-in functions in Google Spreadsheet.
From
[{"text":"QOTD","indices":[13,18]},{"text":"CSEC4CG","indices":[87,95]},{"text":"myCSEC","indices":[96,103]},{"text":"Connecticut","indices":[104,116]},{"text":"GiveBack","indices":[117,126]},{"text":"COVID19","indices":[127,135]}]
To
#QOTD #CSEC4CG #myCSEC #Connecticut #Giveback #COVID19
If my understanding is correct, how about this answer?
Sample formula:
=TRIM(REGEXREPLACE(REGEXREPLACE(A1,"\[|\]|,",""),"{""text"":""(.+?)""""indices"":.+?}"," #$1"))
In this case, it supposes that the input value is put in the cell "A1".
The flow is as follows.
Replace \[|\]|, with "" using REGEXREPLACE.
Replace {""text"":""(.+?)""""indices"":.+?} with " #$1" using REGEXREPLACE.
The top space is removed with TRIM.
Result:
References:
REGEXREPLACE
TRIM

How to put quotation marks around all parts of a Google Sheets formula that are not cell references

I want to be able to see my formulas with actual data in them to help with troubleshooting.
So I want to get a regular expression that will put quotation marks around all non-cell-reference items.
I tried
Original formula
=IFERROR(
(($Q10*24*Q$2)*($O10*$O$2)*( ($T10+$V10)*$S$2)*($P10*$P$2))/($R10*$R$2),"Spec missing")
Desired output
="IFERROR(
(("&$Q10&"*24*"&Q$2&")*("&$O10&"*"&$O$2&")*( ("&$T10&"+"&$V10&")*"&$S$2&")*("&$P10&"*"&$P$2&"))/("&$R10&"*"&$R$2&"),""Spec missing"")"
When I copy the output and paste as text, I want to get a formula in the cell that outputs text looks like this:
="IFERROR(
((0.363194444444444*24*1)*(17348*1)*( (4.096+18.874368)*1)*(2519*1))/(3*1),""Spec missing"")"
I can then copy that down and that helps me troubleshoot the formula (or the data) if something weird is happening.
Solution I found:
I copy the formula and paste it in F10 (with an ' in front of it so it comes up as a text string), then paste the following:
="="""&REGEXREPLACE(regexreplace(F2,"\""","\""\"""),"(\$?[A-Z]{1,2}\$?\d+)","""&$1&""")&""""
Description: i) The first regexreplace (going from innermost to outermost) I use to escape all the quotes in the formula by replacing all double quotes with two double quotes, so that quotes in the original formula won't mess things up. ii) The second REGEXREPplace finds things that match the "$A1" (or "A1" or "A$1") pattern, allowing up to two letters (eg. "AA1" will work as well). iii) I put "="""& before and &"""" and after to finish the formula.
One problem I still have with this setup is that it doesn't handle cell references in another worksheet, such as "Rankings!A1". I'm not sure what sort of regular expression I'd be able to use that could match everything before the "!" that could be part of a sheet name without starting to match other things . . .