Formula Parse Error with double quotes in Regex expression - google-sheets

I'm trying to add a Regex expression to REGEXMATCH, but every time I try Google sheets adds a closing parenthesis and breaks the formula giving me a parse error. I'v tried to escape the single quote, double quote and parenthesis, but with no luck any tips? also tried to add the regex to a cell and reference that, but didn't behave as expected
this is the regex I'm trying to add ['"(]

you will need to double them like:
['""(]
example: https://stackoverflow.com/a/66028064/5632629

Related

Remove characters in Googlesheets

I want to remove the first and last characters of a text in a cell. I know how to remove just the first or the last with formulas such as =LEFT(A27, LEN(A27)-1) but i want to combine two formulas at the same time for first and last character or maybe there is a formula that I'm not aware of which removes both (first and last characters) at the same time.
I know about Power Tool but i want to avoid using this tool and I'm trying to realize this simply by formulas.
You could use the REGEXREPLACE() function:
=REGEXREPLACE(A27, "^.|.$", "")
The regular expression used here matches:
^. the first character after the start of the string
| OR
.$ the last character of the string
better not to use this but it works too:
=RIGHT(LEFT(A27, LEN(A27)-1), LEN(LEFT(A27, LEN(A27)-1))-1)
=LAMBDA(x, RIGHT(LEFT(A27, x), LEN(LEFT(A27, x))-1))(LEN(A27)-1)
=LAMBDA(x, LAMBDA(y, RIGHT(y, LEN(y)-1))(LEFT(A27, x)))(LEN(A27)-1)
=LAMBDA(x, RIGHT(x, LEN(x)-1))(LEFT(A27, LEN(A27)-1))

How can I make quotation marks act as normal text within a regex function?

I'm trying to use regex to extract information from a large text file on google sheets, but within the regex, I'm using quotation marks, and instead of treating everything like the text I want to use, the quotation marks make it so that the regex splits into many different parts. Is there some character I can add to prevent this?
As an example, say I used =REGEXEXTRACT("name"="",""name"="(\w+)"")
It would basically split this into:
REGEXEXTRACT(
"name"
=
""
,
""
name
"="
(\w+)
"")
and would return a formula parse error.
Is there any way I can cancel out certain quotation marks?
Solution:
You can escape double quotes by... another double quote!
So if your first formula argument is name"=" and your second formula argument is "name"="(\w+)", you would use:
=REGEXEXTRACT("name""=""","""name""=""(\w+)""")
Output: (note that I used concatenate to show the expressions)

SUBSTITUTE within ARRAYFORMULA in Google Sheets

I am trying to perform a text replacement over multiple cells. I'm sure I can do this using ARRAYFORMULA, but I'm not sure how to feed SUBSTITUTE with an array rather than a single value.
I have tried using =ARRAYFORMULA(SUBSTITUTE(A1:A, '&', '&')) but this gives a formula parse error.
What is the correct formula to use?
You need to use the double quotation marks " instead of the single quotation marks '
=ARRAYFORMULA(SUBSTITUTE(A1:A, "&", "&"))

Extract text between quotation marks google sheets

Looking to take a string along the lines of:
"text": "fkjhsabhfkjhs7g8ydfgd.",
"e": 1541699908958,
"test": true
and only extract the characters between the text field...so end up with only fkjhsabhfkjhs7g8ydfgd.
The length of the text field can vary
Tried this: =REGEXEXTRACT(C2,"""(.*?)""") with no luck
I found that if you escape the double double quotes, that it works. The other examples don't appear to work in Google Sheets regexextract function
=REGEXEXTRACT(C2,"\""(.*?)\""")
An alternative solution could be
=regexextract(C2, "\:\s""(.+?)""")
I'm not sure if Excel does capture groups properly, but if your input has no double quotes inside, you could try:
=REGEXEXTRACT(C2, "[^""]+")
which matches up to the second double quote (eg. matches abc in "abc"d").
Change A1 with your designated cell number and it should work
=REGEXEXTRACT(A1,"""(.*?)""")

sheets REGEXEXTRACT - extract text between square brackets

I have a cell in E13 which contains numbers and numbers between brackets.
What I want to acheive is to match the number and copy to another cell and delete the match from E13.
E13
0:08.63 [6]
I want E13 to be
0:08.63
And in M13 I want
6
Based on this example https://support.google.com/docs/answer/3098244?hl=en
=REGEXEXTRACT(A4, "\(([A-Za-z]+)\)")
I tried this in M13
=REGEXEXTRACT(E13,\([[0-9]+]\))
Then based on this SO answer https://stackoverflow.com/a/2403159/461887
=REGEXEXTRACT(E13,\[(.*?)\])
But in both cases I just get an error.
SPLIT by the space:
=SPLIT(E13," ")
REGEX:
=REGEXEXTRACT(E13,"(\S+)\s+\[(\d+)\]")
You are just getting a basic syntax error. The minimal help for REGEXEXTRACT shows that the regexp must be enclosed in double quotes. Your second expression works correctly then:
=REGEXEXTRACT(E13,"\[(.*?)\]")

Resources