I want to cut out substrings from this url XYZ.com/de/haus/dach/ and put the values each in its own columns in Google Spreadsheet.
With this url example:
Column A should be "de"
Column B should be "haus"
Column C should be "dach"
How can I do that?
Remove the characters before the first /. This can be done in a number of ways, including REGEXREPLACE or through a combination of RIGHT, LEN and FIND.
SPLIT the resulting string.
=SPLIT(RIGHT(A1,(LEN(A1)-(FIND("/",A1)))),"/")
Related
I want to cut out substrings from this url XY.com/de/haus/dach-ziegel-stein/ and put the values each in its own columns in Google Spreadsheet.
I want to cut out by / and by -.
With this url example:
Column A should be de
Column B should be haus
Column C should be dach
Column D should be ziegel
Column E should be stein
You can use the following single formula for a range
=INDEX(IFERROR(SPLIT(
REGEXREPLACE(
REGEXREPLACE(A125:A128,"^\w+\.\w+\/"," "),
"\/|\-"," ")," ")))
(do adjust ranges and locale according to your needs)
Or simpler
=INDEX(IFERROR(SPLIT(
REGEXREPLACE(A125:A128,"\w+\.\w+\/"," "),"/|-")))
Functions used:
INDEX
IFERROR
SPLIT
REGEXREPLACE
You can use a split formula like so to split by multiple delimiters:
=SPLIT(REGEXREPLACE(right(A1,len(A1)-(find(".com",A1)+3)), "-|/", "😎"), "😎")
This formula works by first trimming off the first part of the URL:
right(A1,len(A1)-(find(".com",A1)+3)
It finds where the end of the url, .com, starts within the string, and then adds 3 to get the end of the url (ie in the example URL, XY.com/..., .com starts at position 3, so we add 3 to compensate for the c o m, which gets us an ending position of 6).
From there, we trim the URL starting on the right hand side, getting the length of the entire URL minus the ending position of the .com.
Finally, we replace the two delimiters that we want to split by with a unicode character, in this case 😎.
REGEXREPLACE(right(A1,len(A1)-(find(".com",A1)+3)), "-|/", "😎")
And then simply split that string by the unicode character, effectively splitting by both - and /.
This is the example sheet.
Alright, in cell V1!A1 is the formula ={"Languages";ARRAYFORMULA(TRANSPOSE(QUERY(TRANSPOSE(B2:F&","),,COLUMNS(B2:F))))}. I need to combine data from B2:F with the delimiter ,. But now I need to delete the unnecessary delimiters.
In sheet V2, I tried ={"Languages";ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(TRANSPOSE(QUERY(TRANSPOSE(B2:F&","),,COLUMNS(B2:F))),"(^(,(\s,){4})$)|(^(,\s)+)|(,(\s,)?\s?$)",""),"(,\s,)+\s?",", "))} but it's not consistant and still leaves delimiters in the output.
Is there a better way to do this?
I added a sheet called "Erik Help" which replaces your formula with the following:
=ARRAYFORMULA({"Languages";SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(B2:F&" "),,COLUMNS(B2:F))))," ",", ")})
Essentially, instead of appending a comma to elements of the range B2:F, I appended a space. Then I applied TRIM to the results, which will leave no spaces before or after each concatenation and only one between each element. To that, I applied a SUBSTITUTE of the single spaces with a comma-space.
I have a cell with a variable number of substrings separated by a comma.
To search:
"first,second,third"
"primero,segundo,tercero,cuarto"
"eins,zwei"
and I have a column with many strings that are composed by some of the substrings:
Column with full items
"first,second,third,fourth"
"primero,segundo,tercero,cuarto,quinto"
"primero,tercero,cuarto"
"eins,zwei,drei"
...and so on...
I would like to find the items of the Column above which has the substrings to be searched. Not a big issue when the amount of substrings is fixed but when it varies it becomes harder. I have a horrible formula that counts the number of commas and then it uses IF for each amount of substrings to search and several FIND(index(SPLIT(A4,","),2) for each substring. The formula is gigant and hard to handle.
Can you think of a better way of doing it?
Here there is an example of what I would like to do. The blue cells are the ones that should have the formula.
https://docs.google.com/spreadsheets/d/1pD9r4JF48cVSNGqA4D69lSyasWxTvAcOhWWu1xW2mgw/edit?usp=sharing
Thanks in advance!
Thank you all for your help! In the end, I used the QUERY function.
=QUERY(E:F,"select E where F contains '" & textjoin("' AND F contains '",TRUE,split(A2,",")) &"'" )
If you are interested, you can see the solution applied in the original spreadsheet :)
I have a list of IDs like this :
40316C1
40316433D112
4316C1
4Z2
40316B2
40310
I would like to return the IDs like this:
40316
40316433
4316
4
40316
40310
Basically, from the first alphabet Character, Trim or Split the rest on the right.
Can I do this in Google Sheets?
You can do it with REGEXEXTRACT
Sample:
=REGEXEXTRACT(A1,"\d{1,20}")
This formula will evaluate the first 20 characters of the IDS (you can change 20 to ahigher number if necessary`
\d means that the formula will extract only numbers from the IDs - until it finds the first non-number.
UPDATE:
The case of no text characters existing in the cell can be caught with =IFERROR
=IFERROR(REGEXEXTRACT(A5,"\d{1,20}"),A5)+0
How do I remove non-numerical characters from a filter in Google Sheets?
I have a function that spits out matching phone numbers into up to 3 subsequent columns. I would like to eliminate non-number characters and a prevailing 1 if there is one, possibly using Regex.
=array_constrain(transpose(filter(People!H:H,People!B:B=A10)),1,3)
=ARRAYFORMULA(IFERROR(REGEXREPLACE(TO_TEXT(A1:A), "\D+|^1", "")))