How can I extract a reference id from a URL to display in another column on Google Spreadsheets?
The URL is: https://www.linkedin.com/jobs/view/1208668091/?eBP=NotAvailableFromVoyagerAPI&refId=272d49e6-406a-4596-8720-f2287fb99331&trk=d_flagship3_search_srp_jobs
And in that exemple, I want to extract: 1208668091
Assuming the url is in A1, see if this works
=regexextract(A1, "/(\d+)/")
Depending on your locale, you may have to change the comma with a semi-colon.
Related
I have a Google sheet with hundreds of images URLs from Dropbox and I want to write a regex that will find all the prefixes part of the URLs without the file name + extension. I'll then replace the search result with another url.
What I have:
https://www.dropbox.com/s/dtauvpuy3a5qyu4/A1001.jpg
https://www.dropbox.com/s/dtauvpuy3a5qyu4/A1001.jpg
https://www.dropbox.com/s/dtauvpuy3a5qyu4/A1001.jpg
https://www.dropbox.com/s/d0xedx0j72v5uub/A1002-1.jpg
https://www.dropbox.com/s/d0xedx0j72v5uub/A1002-1.jpg
What I expect:
https://anotherurl.com/A1001.jpg
https://anotherurl.com/A1001.jpg
https://anotherurl.com/A1001.jpg
https://anotherurl.com/A1002-1.jpg
https://anotherurl.com/A1002-1.jpg
Please, how can I do that?
Suppose your original URLs are in the range A2:A of some sheet. Clear some other column entirely (e.g., B:B), and place the following formula in B2:
=ArrayFormula(IF(A2:A="",,REGEXREPLACE(A2:A,"(.+//).+(/[^/]+)$","$1"&"another.url"&"$2")))
Where you see "another.url", you can either manually enter some other URL text between the quotation marks, or you can enter the new URL text is some cell (say, B1) and use the cell reference instead:
=ArrayFormula(IF(A2:A="",,REGEXREPLACE(A2:A,"(.+//).+(/[^/]+)$","$1"&B1&"$2")))
I'm trying add easy updating prices into a google sheet.
I need the market price from
//*[#id="app"]/div/section[2]/section/div[1]/section[3]/div/section[1]/ul/li[1]/span[2]
https://www.tcgplayer.com/product/242811/pokemon-celebrations-celebrations-elite-trainer-box?Language=English
I need it to display just the one number from the XPath to a cell, and I can't seem to figure out where I am going wrong. I've been using the IMPORTXML function and it won't return a value.
=IMPORTXML(A2,"//*[#id='app']/div/section[2]/section/div[1]/section[3]/div/section[1]/ul/li[1]/span[2]")
where A2 is the URL.
In your situation, it seems that the value of the market price cannot be directly retrieved from the URL of https://www.tcgplayer.com/product/242811/pokemon-celebrations-celebrations-elite-trainer-box?Language=English. But, fortunately, it seems that that value can be directly retrieved from the endpoint of API. So, how about the following sample formula?
Sample formula:
=REGEXEXTRACT(JOIN(",",IMPORTDATA(A1)),"marketPrice:(.+?),")*1
or
=REGEXEXTRACT(QUERY(TRANSPOSE(IMPORTDATA(A1)),"WHERE Col1 matches 'marketPrice.+'"),"marketPrice:(.+)")*1
The cell "A1" has the URL of https://mpapi.tcgplayer.com/v2/product/242811/details.
In the case of https://www.tcgplayer.com/product/242811/pokemon-celebrations-celebrations-elite-trainer-box?Language=English, please use 242811 from the URL to the endpoint of API like https://mpapi.tcgplayer.com/v2/product/242811/details.
Result:
Note:
The value from the URL is JSON data. In this case, the following custom function can be also used. In this case, please copy and paste the following script to the script editor of Spreadsheet and save the script. And please put a custom function of =SAMPLE("url") to a cell.
const SAMPLE = url => JSON.parse(UrlFetchApp.fetch(url).getContentText()).marketPrice;
References:
IMPORTDATA
REGEXEXTRACT
Custom Functions in Google Sheets
it's not possible to scrape JS content into google sheets:
A user pastes in a value to see if there is a full or partial match. I need to do a vlookup and keep removing characters until there is a match. A full match of something like test1.test2.test3 is no problem because it's a full match to my list. But if someone pastes in something like test1.test2.test3.test4, I need to remove a character one at a time from the end until there is a match. So in this example, it would match test1.test2.test3 and return that result.
Conceptually I see this as a for loop that counts the characters using len, using left to remove the number of characters from the end based on the current iteration, and doing vlookups until returning the value when true. But I'm not sure how to do this in Google Sheets.
This formula will give you the matching value that was found in the data(i.e. test1.test2.test3)
=FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data]))
This formula will give you the matching data and the cell reference where it was found (i.e. test1.test2.test3 # $A$4)
=FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data]))&" # "&CELL("address",INDEX([column_with_data],MATCH(FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data])),[column_with_data],0),1))
Simply copy & paste any of the above formulas next to the cell where users paste a value to look. Then, replace the two references in the square brackets [ ] with the proper coordinates in your sheet:
replace [column_with_data] with the coordinates of the column containing all the stored data (i.e. A1:A)
replace [cell_with_pasted_value_to_look] with the absolute ($col$row)coordinates of the cell where users paste the value to look (i.e. $B$1)
Would it be a problem to download the data from Google sheets, transform the file type to use the for loop in another software, and re-upload? I think your idea for a for loop would work.
It might be quicker if this is a long term project, but not so great if the client is continually monitoring/uploading.
I copy a list of company name from a website, each of them has its hyperlink.
But now I would like to paste the names on column B of a google spreadsheet and the link list on column C.
the sample spreadsheet shows here
Column B shows name and column C shows its link like http://.....
The =HYPERLINK function syntax are as followed
HYPERLINK(url, [link_label])
Is there any way I can make the [link_label] become link url itself?
Or is there any other way to list all the hyperlink of a sheet on a column?
The square brackets in a Google function indicate that the parameter is optional. HYPERLINK defaults to display the link itself if the [link_label] is omitted.
In other words, =HYPERLINK("www.example.com") will display as www.example.com.
See Google's documentation.
How can I extract a specific word or words from a URL to display in another column on Google Spreadsheets? The URL is https://seatgeek.com/bands/katy-perry?p=3 and I have to extract "katy perry" from this URL. I also have to create a second formula that will display the same URL with a date from another column on the spreadsheet.
Look up regular expressions for VBA. This way you can perform pattern matching with a lot of flexibility.
Here:
http://www.macrostash.com/2011/10/08/simple-regular-expression-tutorial-for-excel-vba/
or better yet, here:
How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops
How's this - change A3 as needed to match the Cell with the URL:
=SUBSTITUTE(MID(A3,SEARCH(";",SUBSTITUTE(A3,"/",";",4))+1,FIND("?",SUBSTITUTE(A3,"/",";",4))-SEARCH(";",SUBSTITUTE(A3,"/",";",4))-1),"-"," ")
What this is doing is switching out the '/' right before 'katy-perry' with a unique (to that cell) mark, the semi-colon. Then, using MID(), extract the info between the substituted ';' and the '?'.
Edit: This should work with any name length (i.e. 'katy-perry','katyyyyyy-peeerrryyy'). Note that it assumes that you will ALWAYS have a URL with four '/' before the artist's name.
The single sample URL you provided leaves one wondering if the configuration is going to be standard across many other URLs you may have listed. If this is typical of the way other URLs are constructed, you can identify the question mark and the last forward slash to parse out the katy-perry. Here is is in steps then altogether.
The following instructions assume that https://seatgeek.com/bands/katy-perry?p=3 is in A1.
Append a question mark to the end just in case there isn't one in the URL and use the first question mark found to strip off anything right of that.
=LEFT(A1, FIND("?", A1&"?")-1)
Replace all forward slashes with 99 spaces.
=SUBSTITUTE(LEFT(A1, FIND("?", A1&"?")-1), "/", REPT(" ", 99))
Peel off the right-most 99 characters and trim off extra spaces.
=TRIM(RIGHT(SUBSTITUTE(LEFT(A1, FIND("?", A1&"?")-1), "/", REPT(" ", 99)), 99))
The result should katy-perry. This formula is Google-Spreadsheet friendly.