Adding nofollow to specific internal paths I am looking to add nofollow to specific internal paths when they appear within text anywhere in the posts.

I tried using the text filters but I only get the options to either nofollow all links within a post body or nofollow all external links.

What I am trying to achieve is to nofollow all links following this pattern (/user/* ) when they appear within text body.

What are my options? Custom filter? or a preg replace through preprocess. I will appreciate a bit detailed explanation as I am new to programming.

Thanks in advance.
Since you want to add this attribute only to custom URLs (those matching /user/*) within your content, you might have to write custom code, as I'm not aware of any module which does this.

You could use hook_preprocess_field() and then execute a regular expression to match your pattern and add the rel="nofollow" attribute. However, this could be highly inefficient, as you have to do it every time you render a node, besides the fact that parsing HTML with regular expressions is not a bullet-proof solution. 

Here it's a very simple example that just adds rel="nofollow" to all links in the body field (you will have to adapt it to use your own regular expression).

/**
 * Implements template_preprocess_field().
 */
function MYTHEME_preprocess_field(&amp;$variables) {
  if ($variables['element']['#field_name'] == 'body') {
     $markup = $variables['items']['0']['#markup'];
     $variables['items']['0']['#markup'] = preg_replace('/href=/', 'rel="nofollow" href=', $markup);
  }
}


Another alternative would be using the Path Nofollow module, that does something similar: 


  Specify paths on which a metatag is added to prevent search engines
  from indexing the page.


So you could specify the path /user/* and it will add a metatag in the head of your html &lt;meta name="robots" content="noindex"&gt;. As I said, not exactly the same, but it might help or complement your goal.