REGEXEXTRACT multiple values - Google Sheets - regex

I have the following entries in ONE google sheets cell
12#xy.de; 123#xy.de; 1234#xy.de; ext!abc#def.de!; 321#xy.de; ext!def#abc.de!; 4321#xy.de;
Now I would like to create the following output (in one cell aswell) using formulas.
Expected Result:
abc#def.de; def#abc.de
I tried using REGEXEXTRACT but this function only return the first
match (abc#def.de)
Any proposals?

try:
=ARRAYFORMULA(TRIM(TEXTJOIN("; "; 1; IF(REGEXMATCH(
SPLIT(A1; ";"); "abc#def.de|def#abc.de"); SPLIT(A1; ";"); ))))

Related

If text match in range conditonal formula Google Sheets error

I'm trying to get a match in a range of text in Google Sheets basically I'm using this formula:
=IF(REGEXMATCH(H2:M2, "Hi"), "Yes", "No")
But I'm getting an error that is:
You are referencing an array in a function that is not designed to take arrays as input so you need to enable them.
Try:
=ArrayFormula(IF(REGEXMATCH(H2:M2, "Hi"), "Yes", "No"))
I'm trying to do this: =IF(("Hi"=H2:L2),"Approve","No qualify") =IF(("Here"= H2:L2),"Approve","No qualify")
Assuming E1:E2 is the list of values to check against A1:C1, you can try:
=ArrayFormula(if(countif(E1:E2,A1:C1),"Approved","Not qualified"))

Skip translating words with %% and [] in Google Sheets

I am using GoogleTranslate() with Sheets to translate some contents into different languages. In those contents, we have multiple hooks [ ] and % % in one string that do not need to translate. Example :
[name] [surname] looked at your profile %number% !
I do not need to translate hooks like [username] and %number%.
I'm looking for :
[name] [surname] a regardé ton profil %number% ! (in french for example)
A solution is already provided here for one character using REGEXREPLACE and REGEXEXTRACT. But I need either symbol [xxx] and %xxx% in one formula. Thank you.
Alternatively, instead of using the GOOGLETRANSLATE with multiple nested functions, you can try creating a bound script on your spreadsheet file & then copy/paste the simple custom script below that contains translate() function for a more simplified use of function on your sheet:
CUSTOM SCRIPT
function translate(range) {
var container = [];
//KEEP ALL %***% and [***] INTO A CONTAINER
var regex = /(\[.*?])|(\%.*?%)/gm,
stringTest = range,
matched;
while(matched = regex.exec(stringTest)){
container.push(matched[0]);
}
//TRANSLATE TEXT TO FRENCH FROM ENGLISH W/O %***% and [***]
var replacedData = stringTest.replace(regex,'#');
var toTranslate = LanguageApp.translate(replacedData, 'en', 'fr');
var res = "";
//REARRANGE THE TRANSLATED TEXT WITH %***% and [***] FROM CONTAINER
for(x=0;x<toTranslate.split("#").length;x++){
res = res + toTranslate.split("#")[x]+" "+container[x];
}
//RETURN FINAL TRANSLATED TEXT WITH UNMODIFIED %***% and [***]
return res.trim().replace("undefined","");
}
SAMPLE RESULT
After saving the script, just simply put =translate(A1) (e.g. the text you want to translate is on cell A1) on a sheet cell and the script will skip any multiple words inside [***] & %***%, then it will only translate the rest of the text to french.
Try this:
=arrayformula(if(A1<>"",join("",if(isnumber(flatten(split(GOOGLETRANSLATE(join(" ",iferror(regexreplace(to_text(flatten(split(A1," "))),"(\[.*\])|(\%.*\%)","["&row(A$1:A)&"]"),)),"en","fr"),"[]"))),vlookup(flatten(split(GOOGLETRANSLATE(join(" ",iferror(regexreplace(to_text(flatten(split(A1," "))),"(\[.*\])|(\%.*\%)","["&row(A$1:A)&"]"),)),"en","fr"),"[]")),{sequence(len(regexreplace(A1,"[^\ ]",))+1,1),flatten(split(A1," "))},2,false),flatten(split(GOOGLETRANSLATE(join(" ",iferror(regexreplace(to_text(flatten(split(A1," "))),"(\[.*\])|(\%.*\%)","["&row(A$1:A)&"]"),)),"en","fr"),"[]")))),))
GOOGLETRANSLATE does not work with ARRAYFORMULA, but you can drag down this formula from cell B1 if you want to apply it to multiple rows in column A.
Individual steps taken:
Split text by space character, then flatten into one column.
Cell D1: =flatten(split(A1," "))
Replace [***] and %***% with [row#].
Cell E1: =arrayformula(iferror(regexreplace(to_text(flatten(split(A1," "))),"(\[.*\])|(\%.*\%)","["&row(A$1:A)&"]"),))
Join the rows into one cell.
Cell F1: =join(" ",E:E)
Apply Google Translate.
Cell G1: =GOOGLETRANSLATE(F1,"en","fr")
Split by [].
Cell H1: =flatten(split(G1,"[]"))
Where rows contain numbers, lookup item 1) above.
Cell I1: =arrayformula(if(isnumber(H1:H),vlookup(H1:H,{row(A$1:A),D:D},2,false),H1:H))
Join the rows into one cell.
Cell J1: =join(" ",I:I)

How to find and return a value based on more than one text value in a column in Google Sheets

I am trying to extract relevant links from a huge list of links based on the text that is present in A:A. I have succeeded in extracting relevant links based on the value in A:A using the following formula:
=ArrayFormula({"Profile";if(len("*"&A2:A&"*"),iferror(vlookup(substitute("*"&C2:C&"*"," ","-")&"-"&"*"&A2:A&"*",{regexextract(D2:D,"^.+/(.+)\..+$"),D2:D},2,)),)})
Here is the URL to the Google Sheet
https://docs.google.com/spreadsheets/d/1Y1emSB2G2h_d1AIHNAqP6pIsG6-tK4sIIVCBGGjVd4g/edit?usp=sharing
The challenge I'm facing is that the formula returns blank results when a row in A:A contains more than one name i.e first and last names. I have tried all means but I can't get it to work when the value in the first column contains more than one name.
Please assist me if you know the solution to this.
try:
={"Profile"; ARRAYFORMULA(IFNA((VLOOKUP(REGEXEXTRACT(LOWER(A2:A), TEXTJOIN("|", 1,
IFNA(REGEXEXTRACT(E2:E, LOWER(TEXTJOIN("|", 1, SUBSTITUTE(A2:A, " ", "|"))))))), {
IFNA(REGEXEXTRACT(E2:E, LOWER(TEXTJOIN("|", 1, SUBSTITUTE(A2:A, " ", "|"))))), E2:E}, 2, 0))))}

Google Sheet: Filtering multiple values in a single cell

I'm trying to filter a column and the result should contain both the word "biology" and "aqa".
I'm using this formula now:
=regexmatch(A:A, "biology|aqa"
But the result also contains words that have biology or aqa only like:
biology-a2-unit-1
biology-a2-unit-4
biology-alevel
aqa-alevel
alevel-aqa-unit-1
My expected result should have both "biology" and "aqa" only like:
biology-aqa
biology-aqa-a-level
biology-aqa-gcse
as-biology-aqa
aqa-biology-gcse
you are using | which is OR logic. but you need AND logic
=FILTER(A:A, REGEXMATCH(A:A, "aqa"), REGEXMATCH(A:A, "biology"))

Google Script - Find and Replace using "Search Within Formulas"

I have a google sheet that receives a list of phone numbers from an outside source. Phone numbers arrive in one of two formats:
Numbers that appear as 12345678901 are seen without error.
Numbers that appear as 1(234)567-8901 result in #ERROR!.
It seems that google sheets is reading the second set of numbers as a formula. When I click into an error cell, the phone number is preceded with "=+", as in "=+1(234)567-8901". I can fix this manually for the entire document by using Find and Replace with "Search within Formulas" checked.
Find: "=+"
Replace: " "
Is there any way to automate this within google apps scripts? I would like to run this function onEdit() so that #ERROR! phone numbers are fixed in real time.
You can remove the ()- characters using a spreadsheet formula, let's say the number was in cell A1, then in another cell you can put:
=CONCATENATE(SPLIT(A1, "()-" ))
which will remove the ()- characters.
If you would like to do this with a script then you can use replace to remove the ()-
.replace(/[()-]/gi, "")
apply above your number column range to properly format number.
EDIT
This should work, change "A1:A" to your column
function onEdit(){
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:A" + sheet.getLastRow());
var data = range.getValues();
var formulas = range.getFormulas();
for (var i=0;i< formulas.length;i++) {
if(typeof formulas[i] !== "undefined" && formulas[i] != ""){
formulas[i][0] = formulas[i][0].replace(/[=()+-]/gi, "");
data[i][0] = formulas[i][0].toString();
}
}
range.setValues(data).setNumberFormat("0");
}