Insert rel=nofollow in link if not present

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

gerd
Posts: 39
Joined: Wed Mar 12, 2008 10:52 pm

Insert rel=nofollow in link if not present

Postby gerd » Wed Mar 27, 2013 1:31 am

Hi,
I am struggling with the inserting of rel="nofollow" in all links within a certain text block if the link does not has this string.
Example of the textblock:
<!--menu2-->
...
<!--menu3-->

Insert in all links within the textblock <!--menu2-->(.*)<!--menu3--> after
the two characters
<a
shoulds read now <a rel="nofollow"
if the string rel="nofollow" is not already there. So <a class=" will become <a rel="nofollow" class="

My problem is the detection of the string
rel="nofollow"
in existing links

As a workaround I could just insert rel="nofollow" in all links and delete thereafter the string
rel="nofollow" rel="nofollow" to just rel="nofollow"
but the problem is that there other strings like class="..." target="_..." etc. which appear in some links in different places. Thus, I cannot detect if the string rel="nofollow" is already there. Do you have any idea of the filter?
thanks
gerd

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Insert rel=nofollow in link if not present

Postby DataMystic Support » Wed Mar 27, 2013 2:27 pm

Hi Gerd,

Please find a filter attached to do this.

Here is the text structure for reference too:

Code: Select all

|--Perl pattern [<!--menu2-->(.*)<!--menu3-->] with []
|  |  [ ] Match case
|  |  [ ] Whole words only
|  |  [ ] Case sensitive replace
|  |  [ ] Prompt on replace
|  |  [ ] Skip prompt if identical
|  |  [ ] First only
|  |  [ ] Extract matches
|  |  Maximum text buffer size 4096
|  |  [ ] Maximum match (greedy)
|  |  [ ] Allow comments
|  |  [X] '.' matches newline
|  |  [ ] UTF-8 Support
|  |
|  +--Perl pattern [<a [^>]*>] with [$0]
|     |  [ ] Match case
|     |  [ ] Whole words only
|     |  [ ] Case sensitive replace
|     |  [ ] Prompt on replace
|     |  [ ] Skip prompt if identical
|     |  [ ] First only
|     |  [ ] Extract matches
|     |  Maximum text buffer size 4096
|     |  [ ] Maximum match (greedy)
|     |  [ ] Allow comments
|     |  [X] '.' matches newline
|     |  [ ] UTF-8 Support
|     |
|     |--Perl pattern [rel="[^"]*"] with []
|     |     [ ] Match case
|     |     [ ] Whole words only
|     |     [ ] Case sensitive replace
|     |     [ ] Prompt on replace
|     |     [ ] Skip prompt if identical
|     |     [ ] First only
|     |     [ ] Extract matches
|     |     Maximum text buffer size 4096
|     |     [ ] Maximum match (greedy)
|     |     [ ] Allow comments
|     |     [X] '.' matches newline
|     |     [ ] UTF-8 Support
|     |   
|     +--Perl pattern [<a ] with [<a rel="nofollow" ]
|           [ ] Match case
|           [ ] Whole words only
|           [ ] Case sensitive replace
|           [ ] Prompt on replace
|           [ ] Skip prompt if identical
|           [ ] First only
|           [ ] Extract matches
|           Maximum text buffer size 4096
|           [ ] Maximum match (greedy)
|           [ ] Allow comments
|           [X] '.' matches newline
|           [ ] UTF-8 Support
|         
Attachments
html add nofollow to a tags.zip
(1.5 KiB) Downloaded 215 times
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

gerd
Posts: 39
Joined: Wed Mar 12, 2008 10:52 pm

Re: Insert rel=nofollow in link if not present

Postby gerd » Fri Mar 29, 2013 3:52 am

Thanks Simon,
this a great solution.
gerd


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 3 guests