Create hyperlinks in Exsisting Table
-
I converted a TSV to HTLM and I want to add some hyperlinks to each song name and there are too many to do manually.
So =POPSONG will link to
httXX://mysongs.com/songs/=POPSONG.mp3This is one of many:
<tr> <td>=POPSONG</td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr> -
Hello, @musocity and All,
From your INPUT file, below :
<tr> <td>=POPSONG</td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>Use the following regex search :
-
SEARCH
(?-s)^(\h+)<td>(=.+)</td> -
REPLACE
${0}\r\n${1}httXX://mysons\.com/songs/${2}\.mp3
And you should get this OUTPUT text :
<tr> <td>=POPSONG</td> httXX://mysons.com/songs/=POPSONG.mp3 <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>Best Regards,
guy038
-
-
Hi, @musocity and All,
Ouuuups ! Sorry I misunderstood your need ! May be you prefer this OUTPUT :
<tr> <td>httXX://mysons.com/songs/=POPSONG.mp3</td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>If so , juste modify the previous S/R as :
-
SEARCH
(?-s)=.+(?=</td>) -
REPLACE
httXX://mysons\.com/songs/${1}\.mp3
BR
guy038
-
-
I need
d><a href="https://mysongs.com/songs/=POPSONG.mp3" title="">=POPSONG</a></td>the above SR gives me (using RegEx)
<td>https://mysongs.com/songs/.mp3</td> -
@MusoCity Try:
Find what:(<tr>\s*\R\s*<td>)(.+)</td>
Replace with:$1<a href="https://mysongs.com/songs/$2.mp3" title="">$2</a></td>However, this will still be problematic if your song titles include blanks or other characters that should be encoded in URLs. I would have to think a while longer if there is any reasonable way to fix that.
-
I said in Create hyperlinks in Exsisting Table:
However, this will still be problematic if your song titles include blanks or other characters that should be encoded in URLs. I would have to think a while longer if there is any reasonable way to fix that.
This is a little slow and clumsy, but after doing the first replacement, you could clean up URLs with something like:
Find what:
("https://mysongs.com/songs/[^"]*) ([^"]*")
Replace with:$1%20$2(note the space between first close parenthesis and the following open parenthesis in the find string); Replace All repeatedly until it doesn’t find anything else.
Then repeat with any other special characters, such as “/” replaced with “%2F”; “:” with “%3A”; and “?” with “%3F”; there might be a faster way, but I don’t know what it is.
-
Thanks ! I think that should do the job
example here:
Xttps://reatrak.com/downloads/biab/style-player/
I set target=“_blank” to open in new tab.
“You need 1 reputation to post links” so change the X to h :( -
Hello, @musocity, @coises and All,
@musocity, I must admit that I shoud have remembered that an
HTMLlink is always defined by a<a>tag, whose thehrefattribute specifies the link’s destination :-(But, in your first post, you textually said :
So =POPSONG will link to
httXX://mysongs.com/songs/=POPSONG.mp3Which is exactly what I did, in my second reply to you !!
Now, if you had posted something like :
I have a lot of
<tr>blocks which, each, defines a song’s name, after the<td>/=charsFor instance, I have this INPUT text :
<tr> <td>=POPSONG</td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>and I would like to get this OUTPUT :
<tr> <td><a href="https://mysongs.com/songs/=POPSONG.mp3" title="">=POPSONG</a></td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>I could have given you the exact answer, straight away !
Now, regarding the replacement of some punctuation chars by their
%encodedequivalent :-
I did not consider the
-,~,_chars and the.dot if followed withmp3, which are non-reserved chars, as well as word chars -
I did not consider, either, the
"double-quotes as well as the<and>chars, extensively used inHTMLfiles
Thus, the remaining characters to test are this list :
!#$ %&'()*+,/:;=?@[]^`{|}Then, I chose this odd name’s song :
!#$ Name%&of'()*+,/:;the=?@[]song^`{|}Followed by
.mp3I found out a regex S/R which treats all these characters and replace them by their
%encodedequivalent, in one go :- SEARCH (?:/=|>=|(?<!\A)\G)(?:(?s-i)(?!\.mp3|</a>).)*?\K(?:(\x20)|(!)|(#)|(\$)|(%)|(&)|(')|(\()|(\))|(\*)|(\+)|(,)|(/)|(:)|(;)|(=)|(\?)|(@)|([)|(\\)|(])|(\^)|(`)|(\{)|(\|)|(\})|(\.(?!mp3))) - REPLACE (?{1}%20)(?{2}%21)(?{3}%23)(?{4}%24)(?{5}%25)(?{6}%26)(?{7}%27)(?{8}%28)(?{9}%29)(?{10}%2A)(?{11}%2B)(?{12}%2C)(?{13}%2F)(?{14}%3A)(?{15}%3B)(?{16}%3D)(?{17}%3F)(?{18}%40)(?{19}%5B)(?{20}%5C)(?{21}%5D)(?{22}%5E)(?{23}%60)(?{24}%7B)(?{25}%7C)(?{26}%7D)(?{27}%2E)I took inspiration from this post :
To test this regex :
- First, copy the following text in a new tab
<tr> <td><a href="https://mysongs.com/songs/=!#$ Name%&of'()*+,/:;the=?@[]song^`{|}.mp3" title="">=!#$ Name%&of'()*+,/:;the=?@[]song^`{|}</a></td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr> <tr> <td><a href="https://mysongs.com/songs/=!#$ Name%&of'()*+,/:;the=?@[]song^`{|}.mp3" title="">=!#$ Name%&of'()*+,/:;the=?@[]song^`{|}</a></td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>-
Move to the very beginning of the file ( IMPORTANT )
-
Open the Replace dialog (
Ctrl + H) -
Un-tick all box options
- SEARCH (?:/=|>=|(?<!\A)\G)(?:(?s-i)(?!\.mp3|</a>).)*?\K(?:(\x20)|(!)|(#)|(\$)|(%)|(&)|(')|(\()|(\))|(\*)|(\+)|(,)|(/)|(:)|(;)|(=)|(\?)|(@)|([)|(\\)|(])|(\^)|(`)|(\{)|(\|)|(\})|(\.(?!mp3))) - REPLACE (?{1}%20)(?{2}%21)(?{3}%23)(?{4}%24)(?{5}%25)(?{6}%26)(?{7}%27)(?{8}%28)(?{9}%29)(?{10}%2A)(?{11}%2B)(?{12}%2C)(?{13}%2F)(?{14}%3A)(?{15}%3B)(?{16}%3D)(?{17}%3F)(?{18}%40)(?{19}%5B)(?{20}%5C)(?{21}%5D)(?{22}%5E)(?{23}%60)(?{24}%7B)(?{25}%7C)(?{26}%7D)(?{27}%2E)-
Select the
Regular expressionsearch mode -
Click once, on the
Replace Allbutton ( Do not use theReplacebutton )
Important :
-
Due to the presence of the
\Ksyntax, in the search regex, you CANNOT use theReplacebutton and must trigger a global replacement ! -
If you just want to know the different occurrences, which will be replaced later, simply use the
Find NextorFind Previousbutton ( orF3/Shift + F3)
And you should get this OUTPUT :
<tr> <td><a href="https://mysongs.com/songs/=%21%23%24%20Name%25%26of%27%28%29%2A%2B%2C%2F%3A%3Bthe%3D%3F%40%5B%5C%5Dsong%5E%60%7B%7C%7D.mp3" title="">=%21%23%24%20Name%25%26of%27%28%29%2A%2B%2C%2F%3A%3Bthe%3D%3F%40%5B%5C%5Dsong%5E%60%7B%7C%7D</a></td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr> <tr> <td><a href="https://mysongs.com/songs/=%21%23%24%20Name%25%26of%27%28%29%2A%2B%2C%2F%3A%3Bthe%3D%3F%40%5B%5C%5Dsong%5E%60%7B%7C%7D.mp3" title="">=%21%23%24%20Name%25%26of%27%28%29%2A%2B%2C%2F%3A%3Bthe%3D%3F%40%5B%5C%5Dsong%5E%60%7B%7C%7D</a></td> <td>R</td> <td>4/4</td> <td>ev8</td> <td>140</td> <td>Pop Piano Lite Solo Piano</td> <td>Ballad</td> <td>Pop 20</td> <td>2009/12</td> <td>RT 70</td> <td>2</td> <td>2</td> <td>Piano Ballad,Air,Celtic,Country Ballad,Worship</td> </tr>
Final clarification :
- Do not run this S/R twice ! Indeed, any
%char of the encoded chars would be encoded as%25again !
Best Regards,
guy038
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login