I have the following value in a cell:
May 04, 2022 (50bp)
I need only what is in between ( and ). I was thinking of using =RIGHT() but I never know how much is inm between the two brackets (so the number of characters I have to give as a parameter to RIGHT(), will differ.
What is the correct way of handling this in Google Sheets?
Use REGEXEXTRACT() function.
=REGEXEXTRACT(A1,"\((.*)\)")
To extract the text between any characters, use a formula with the MID and FIND functions despite how much is in between the two brackets.
=MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1)
more information here
Related
For example i have this in the G33 cell:
Hello (example) world (example 2). How are you (example 3) ?
And i want to remove ALL of the 3 parenthesis with their texts so it becomes:
Hello world. How are you?
I have found some functions but they only remove the first parenthesis.
I want a function that will remove every parenthesis with their contents that exists on a cell.
Can someone provide me with one? I am a begginer in google sheets so my knowledge on functions is very restricted. so please help me
See if this helps
=regexreplace(G33, "(\s\(.*?\))",)
This is sufficient to remove a single level of parenthesis:
=regexreplace(A1,"\([^()]*\)","")
Replacing nested brackets appears challenging, but as a workaround you can nest the function to arbitrary depth like this:
=regexreplace(regexreplace(A1,"\([^()]*\)",""),"\([^()]*\)","")
This assumes that the brackets are correctly matched. You could run a quick check like this:
=len(substitute(A1,"(",""))=len(substitute(A1,")",""))
which at least checks that you have as many right brackets as left ones, but again checking that they are correctly matched would be more difficult.
I have the following extract of code. My aim is to extract the value 7.4e-07 after the symbol DAN. My usual go-to formula (using MID & FIND formula's) for this can't work because DAN is surrounded by ", and therefore confuses the formula.
{"data":{"log":{"address":[{"balances":[{"currency":{"address":"example1","symbol":"ROB"},"value":0.0},{"currency":{"address":"example2","symbol":"DAN"},"value":7.4e-07},{"currency":{"address":"example3","symbol":"COLIN"},"value":0.0},{"currency":{"address":"example4","symbol":"BOB"},"value":0.0},{"currency":{"address":"example5","symbol":"PAUL"},"value":13426.64}}}
I will always need to find the number shown in the 'value' after DAN. However, all other data surrounding will change so cannot be used in the search formula.
Any help would be appreciated.
The extract the digit you want, it can be achieved by using regex, split, index, here is the formula, accept if help :)
=index(split(REGEXEXTRACT(A1,"\""DAN\""},\""value\"":[\d.a-zA-Z-]+"),":"),0,2)
This is the regex I used to extract the value including the beginning text
"DAN"},"value":[\d.a-zA-Z-]+
This is outcome from the regex,
You could try an arrayformula to work down the sheet, extracting all values after 'DAN':
=arrayformula(regexreplace(A1:A,".*(DAN...........)([\w\.\-]*)(\}.*)","$2"))
An answer in this question mentioned you can use ISDATE_STRICT in an array formula, and it worked.
I searched all over and could not find a reference to the use of _STRICT anywhere.
Does this apply to all "IS" check functions?
What exactly is it doing?
Yes, unfortunately, I also don't see any articles/documentations about this one except this.
The link above is a list of sheets formulas, we can see _STRICT on 3 formulas.
ISDATE_STRICT, ISDATETIME_STRICT, ISTIME_STRICT
The link above does answer your first question, it does not apply to all functions IS functions.
Based on their behaviors, I guess that they strictly check if the value is treated and valid as date/time/datetime in sheets itself. Simply passing string as parameter will yield FALSE.
Testing:
Note:
I have a hunch why 25:02:00 for ISTIME_STRICT is still valid for time even though it goes past 24. Sheets automatically converted that value from the inputted value 25:02 thus suggests that what sheets treats as date/time/datetime, will always yield TRUE for those functions.
To test the hypothesis above, I inputted November 31, 2021 1:00 manually and it wasn't converted into 11/31/2021 01:00:00 automatically, it was still the same cell value because it wasn't treated as datetime variable by sheets, thus returning FALSE
I am studying for a test and I would really appreciate some help with this. The instructions are simply to write these formulas in a shorter version. I understand how IF works; if the expression is true, it returns the first value, otherwise the second one (they are separated by semicolons).
Given examples are:
=D$5+IF(C4>1;F8-A12/4-53;F8-A12/4-B12+1)
=IF(C4="test";A4-55+C13;22+(C13+B2+A4))
=C3*IF(AND(C4="P";C5="P");4*A4/(1-m);m*A4-n*A4);
=IF(B3<>0;2*C6;2*IF(B3=2;SIN(omega*t-$A$2);0)
Explanation will be greatly appreciated.
The first formula can be shortened to:
=D$5+F8-A12/4+IF(C4>1;-53;-B12+1)
It's just a matter of factoring out F8-A12 since it is used twice.
To test this, I filled in some numbers into the cells mentioned, and it produced the correct result.
Similarly in the second formula, A4 and C13 are used twice and they could be factored out to be used only once.
In the third formula, everything is getting multiplied by A4 so it could be factored out.
In the fourth formula, it looks like 2 is the only thing that could be factored out.
I have 2D array in which the second column has domain names of some emails, let us call the array myData[][]. I decided to use ArrayLib in order to search the second column for a specific domain.
ArrayLib.indexOf(myData, 1, domain)
Here is where I found an issue. In myData array, one of the domains look like this "ewmining.com" (pay attention to the w).
While searching for "e.mining.com" (notice the first dot), the indexOf() function actully gave me the row containing "ewmining.com".
This is what is in the array "ewmining.com"
This is what is in the serach string "e.mining.com"
It seams that ArrayLib treats the dot to mean any character. Is this supposed to be the correct behavior? Is there a way to stop this behavior and search for exact match.
I really need help on this issue.
Thanks in advance for your help.
The dot usually represents "any character" in regular expressions. I am not familiar with ArrayLib, but maybe you should look for a way to turn off regular expressions when searching. Otherwise you might have to escape the dot, for example search for e[.]mining[.]com