Z
Z
zitrys2021-11-23 21:04:50
Google Sheets
zitrys, 2021-11-23 21:04:50

How to copy a specific word/value from the text of one cell and paste it in a specific place in the text of another cell?

It is required to extract three specific values ​​from the text of the first cell and insert them into another cell in a specific place for each value.

The first cell (just text, value):
www.marinetraffic.com/ru/ais/details/ships/shipid:4643053/mmsi:477636800/imo:9751327/vessel:NING_JING_HAI/

The second cell should be:
www.myshiptracking.com /vessels/NING-JING-HAI-mmsi-477636800-imo-9751327
==========
Somehow I see the second cell
www.myshiptracking.com/vessels/(FORMULA1)-mmsi-(FORMULA2) -imo-(FORMULA3)

Where the data is taken from the first cell
FORMULA1 = NING-JING-HAI (and there should be a lowercase adjustment for a hyphen)
FORMULA2 = 477636800 FORMULA3
= 9751327
==========

So the first URL marinetraffic.com automatically generates the second URL for www.myshiptracking.com)

)
But I don't want to leave this site.
myshiptracking.com is free to parse, but a bit inconvenient.
And I don’t want to look for steamboats on two sites.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2021-11-24
@zitrys

I think you are too hasty with your question.
A good question is half the solution.
For example, let's take a solution with substitution through a regular expression
Regular expression

.*?shipid:([^\/]+).*?mmsi:([^\/]+).*?imo:([^\/]+).*?vessel:([^\/]+).*?

Substitution string
www.myshiptracking.com/vessels/$4-mmsi-$2-imo-$3
From source string
www.marinetraffic.com/ru/ais/details/ships/shipid:4643053/mmsi:477636800/imo:9751327/vessel:NING_JING_HAI/

should work
www.myshiptracking.com/vessels/NING-JING-HAI-mmsi-477636800-imo-9751327

You can use the formula
=REGEXREPLACE(B9,B3,D3)
But, the focus will not work, because the problem is that the source data obviously contains more complex relationships with the result. For example, the name of the ship is written with a lower space " _", while a dash " -" is needed.
619daf24d4434991008817.png
And here is an example with Spreadsheet https://docs.google.com/spreadsheets/d/1WHKGbcyRc1...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question