[ create a new paste ] login | about

Link: http://codepad.org/MwIL5itZ    [ raw code | output | fork | 1 comment ]

RogerPate - Python, pasted on May 20:
input = """
## Java, Java EE

---

**`[applet]`**: `[applets]`, `[java-applet]`, `[java-applets]`  

**`[bean-validation]`**: `[jsr303]`

**`[ejb-3.0]`**: `[ejb3]`, `[ejb-3]`, `[ejb3.0]`  
**`[ejb-3.1]`**: `[ejb31]`, `[ejb-31]`, `[ejb3.1]`  

**`[glassfish-3]`**: `[glassfish3]`, `[glassfishv3]`, `[glassfish-v3]`  

**`[hibernate-3]`**: `[hibernate3]`

**`[java-2d]`**: `[java2d]`  
**`[java-3d]`**: `[java3d]`  

**`[java-1.4]`**: `[java1.4]`, `[java14]`  
**`[java-5]`**: `[java5]`, `[java5.0]`, `[java-5.0]`  
**`[java-6]`**: `[java6]`, `[java6.0]`, `[java-6.0]`  
**`[java-7]`**: `[java7]`, `[java7.0]`, `[java-7.0]`  

**`[java-ee]`**: `[javaee]`, `[jee]`  
**`[java-ee-5]`**: `[javaee5]`, `[javaee-5]`, `[java-ee5]`, `[jee5]`, `[jee-5]`  
**`[java-ee-6]`**: `[javaee6]`, `[javaee-6]`, `[java-ee6]`, `[jee6]`, `[jee-6]`  

**`[java-fx]`**: `[javafx]`  

**`[java-io]`**: `[javaio]`, `[java.io]`  

**`[jax-rs]`**: `[jaxrs]`  

**`[jax-ws]`**: `[jaxws]`

**`[jpa-2.0]`**: `[jpa2]`, `[jpa-2]`, `[jpa2.0]`

**`[jsf-2.0]`**: `[jsf2]`, `[jsf-2]`, `[jsf2.0]`

**`[jsp-tags]`**: `[jsp-tag]`, `[jsp-tag-files]`, `[jsp-tagfiles]`  
**`[jsp-fragments]`**: `[jspfragments]`, `[jsp-fragment]`, `[jspfragment]`, `[jsp-f]`, `[jspf]`

**`[maven-2]`**: `[maven2]`  

**`[servlet]`**: `[servlets]`  
**`[servlet-filter]`**: `[servletfilter]`, `[servlet-filters]`, `[servletfilters]`, `[servlet]`+`[filter]`, `[servlet]`+`[filters]`, `[servlets]`+`[filter]`, `[servlets]`+`[filters]`

**`[tomcat-5.0]`**: `[tomcat5]`, `[tomcat-5]`, `[tomcat5.0]`  
**`[tomcat-5.5]`**: `[tomcat5.5]`  
**`[tomcat-6.0]`**: `[tomcat6]`, `[tomcat-6]`, `[tomcat6.0]`  

**`[weblogic-8.x]`**: `[weblogic8]`, `[weblogic-8]`, `[weblogic8.1]`, `[weblogic-8.1]`, `[weblogic8.x]`  
**`[weblogic-9.x]`**: `[weblogic9]`, `[weblogic-9]` , `[weblogic9.x]`  
**`[weblogic-10.x]`**: `[weblogic10]`,  `[weblogic-10]`, `[weblogic10.x]`  
**`[weblogic-11g]`**: `[weblogic11]`, `[weblogic-11]`, `[weblogic11g]`
""".strip().split("\n")

import re

def g(lines):
  def sub(m):
    tags = [m.group(1)]
    if m.group(2):
      tags += re.sub("[][ `]", "", m.group(2)).strip("+").split("+")
    tags_url = "+".join(tags)
    tags = "[%s]" % "] + [".join(tags)
    return "[%s](http://stackoverflow.com/questions/tagged/%s)" % (tags, tags_url)
  for line in lines:
    if line == "---":
      continue
    if line.startswith("**"):
      line = re.sub(r"`\[([^]`]+)]`( *\+ *`\[[^]`]+]`)* *", sub, line)
    yield line

print re.sub("\n{3,}", "\n\n", "\n".join(g(input)))


Output:
## Java, Java EE

**[[applet]](http://stackoverflow.com/questions/tagged/applet)**: [[applets]](http://stackoverflow.com/questions/tagged/applets), [[java-applet]](http://stackoverflow.com/questions/tagged/java-applet), [[java-applets]](http://stackoverflow.com/questions/tagged/java-applets)

**[[bean-validation]](http://stackoverflow.com/questions/tagged/bean-validation)**: [[jsr303]](http://stackoverflow.com/questions/tagged/jsr303)

**[[ejb-3.0]](http://stackoverflow.com/questions/tagged/ejb-3.0)**: [[ejb3]](http://stackoverflow.com/questions/tagged/ejb3), [[ejb-3]](http://stackoverflow.com/questions/tagged/ejb-3), [[ejb3.0]](http://stackoverflow.com/questions/tagged/ejb3.0)
**[[ejb-3.1]](http://stackoverflow.com/questions/tagged/ejb-3.1)**: [[ejb31]](http://stackoverflow.com/questions/tagged/ejb31), [[ejb-31]](http://stackoverflow.com/questions/tagged/ejb-31), [[ejb3.1]](http://stackoverflow.com/questions/tagged/ejb3.1)

**[[glassfish-3]](http://stackoverflow.com/questions/tagged/glassfish-3)**: [[glassfish3]](http://stackoverflow.com/questions/tagged/glassfish3), [[glassfishv3]](http://stackoverflow.com/questions/tagged/glassfishv3), [[glassfish-v3]](http://stackoverflow.com/questions/tagged/glassfish-v3)

**[[hibernate-3]](http://stackoverflow.com/questions/tagged/hibernate-3)**: [[hibernate3]](http://stackoverflow.com/questions/tagged/hibernate3)

**[[java-2d]](http://stackoverflow.com/questions/tagged/java-2d)**: [[java2d]](http://stackoverflow.com/questions/tagged/java2d)
**[[java-3d]](http://stackoverflow.com/questions/tagged/java-3d)**: [[java3d]](http://stackoverflow.com/questions/tagged/java3d)

**[[java-1.4]](http://stackoverflow.com/questions/tagged/java-1.4)**: [[java1.4]](http://stackoverflow.com/questions/tagged/java1.4), [[java14]](http://stackoverflow.com/questions/tagged/java14)
**[[java-5]](http://stackoverflow.com/questions/tagged/java-5)**: [[java5]](http://stackoverflow.com/questions/tagged/java5), [[java5.0]](http://stackoverflow.com/questions/tagged/java5.0), [[java-5.0]](http://stackoverflow.com/questions/tagged/java-5.0)
**[[java-6]](http://stackoverflow.com/questions/tagged/java-6)**: [[java6]](http://stackoverflow.com/questions/tagged/java6), [[java6.0]](http://stackoverflow.com/questions/tagged/java6.0), [[java-6.0]](http://stackoverflow.com/questions/tagged/java-6.0)
**[[java-7]](http://stackoverflow.com/questions/tagged/java-7)**: [[java7]](http://stackoverflow.com/questions/tagged/java7), [[java7.0]](http://stackoverflow.com/questions/tagged/java7.0), [[java-7.0]](http://stackoverflow.com/questions/tagged/java-7.0)

**[[java-ee]](http://stackoverflow.com/questions/tagged/java-ee)**: [[javaee]](http://stackoverflow.com/questions/tagged/javaee), [[jee]](http://stackoverflow.com/questions/tagged/jee)
**[[java-ee-5]](http://stackoverflow.com/questions/tagged/java-ee-5)**: [[javaee5]](http://stackoverflow.com/questions/tagged/javaee5), [[javaee-5]](http://stackoverflow.com/questions/tagged/javaee-5), [[java-ee5]](http://stackoverflow.com/questions/tagged/java-ee5), [[jee5]](http://stackoverflow.com/questions/tagged/jee5), [[jee-5]](http://stackoverflow.com/questions/tagged/jee-5)
**[[java-ee-6]](http://stackoverflow.com/questions/tagged/java-ee-6)**: [[javaee6]](http://stackoverflow.com/questions/tagged/javaee6), [[javaee-6]](http://stackoverflow.com/questions/tagged/javaee-6), [[java-ee6]](http://stackoverflow.com/questions/tagged/java-ee6), [[jee6]](http://stackoverflow.com/questions/tagged/jee6), [[jee-6]](http://stackoverflow.com/questions/tagged/jee-6)

**[[java-fx]](http://stackoverflow.com/questions/tagged/java-fx)**: [[javafx]](http://stackoverflow.com/questions/tagged/javafx)

**[[java-io]](http://stackoverflow.com/questions/tagged/java-io)**: [[javaio]](http://stackoverflow.com/questions/tagged/javaio), [[java.io]](http://stackoverflow.com/questions/tagged/java.io)

**[[jax-rs]](http://stackoverflow.com/questions/tagged/jax-rs)**: [[jaxrs]](http://stackoverflow.com/questions/tagged/jaxrs)

**[[jax-ws]](http://stackoverflow.com/questions/tagged/jax-ws)**: [[jaxws]](http://stackoverflow.com/questions/tagged/jaxws)

**[[jpa-2.0]](http://stackoverflow.com/questions/tagged/jpa-2.0)**: [[jpa2]](http://stackoverflow.com/questions/tagged/jpa2), [[jpa-2]](http://stackoverflow.com/questions/tagged/jpa-2), [[jpa2.0]](http://stackoverflow.com/questions/tagged/jpa2.0)

**[[jsf-2.0]](http://stackoverflow.com/questions/tagged/jsf-2.0)**: [[jsf2]](http://stackoverflow.com/questions/tagged/jsf2), [[jsf-2]](http://stackoverflow.com/questions/tagged/jsf-2), [[jsf2.0]](http://stackoverflow.com/questions/tagged/jsf2.0)

**[[jsp-tags]](http://stackoverflow.com/questions/tagged/jsp-tags)**: [[jsp-tag]](http://stackoverflow.com/questions/tagged/jsp-tag), [[jsp-tag-files]](http://stackoverflow.com/questions/tagged/jsp-tag-files), [[jsp-tagfiles]](http://stackoverflow.com/questions/tagged/jsp-tagfiles)
**[[jsp-fragments]](http://stackoverflow.com/questions/tagged/jsp-fragments)**: [[jspfragments]](http://stackoverflow.com/questions/tagged/jspfragments), [[jsp-fragment]](http://stackoverflow.com/questions/tagged/jsp-fragment), [[jspfragment]](http://stackoverflow.com/questions/tagged/jspfragment), [[jsp-f]](http://stackoverflow.com/questions/tagged/jsp-f), [[jspf]](http://stackoverflow.com/questions/tagged/jspf)

**[[maven-2]](http://stackoverflow.com/questions/tagged/maven-2)**: [[maven2]](http://stackoverflow.com/questions/tagged/maven2)

**[[servlet]](http://stackoverflow.com/questions/tagged/servlet)**: [[servlets]](http://stackoverflow.com/questions/tagged/servlets)
**[[servlet-filter]](http://stackoverflow.com/questions/tagged/servlet-filter)**: [[servletfilter]](http://stackoverflow.com/questions/tagged/servletfilter), [[servlet-filters]](http://stackoverflow.com/questions/tagged/servlet-filters), [[servletfilters]](http://stackoverflow.com/questions/tagged/servletfilters), [[servlet] + [filter]](http://stackoverflow.com/questions/tagged/servlet+filter), [[servlet] + [filters]](http://stackoverflow.com/questions/tagged/servlet+filters), [[servlets] + [filter]](http://stackoverflow.com/questions/tagged/servlets+filter), [[servlets] + [filters]](http://stackoverflow.com/questions/tagged/servlets+filters)

**[[tomcat-5.0]](http://stackoverflow.com/questions/tagged/tomcat-5.0)**: [[tomcat5]](http://stackoverflow.com/questions/tagged/tomcat5), [[tomcat-5]](http://stackoverflow.com/questions/tagged/tomcat-5), [[tomcat5.0]](http://stackoverflow.com/questions/tagged/tomcat5.0)
**[[tomcat-5.5]](http://stackoverflow.com/questions/tagged/tomcat-5.5)**: [[tomcat5.5]](http://stackoverflow.com/questions/tagged/tomcat5.5)
**[[tomcat-6.0]](http://stackoverflow.com/questions/tagged/tomcat-6.0)**: [[tomcat6]](http://stackoverflow.com/questions/tagged/tomcat6), [[tomcat-6]](http://stackoverflow.com/questions/tagged/tomcat-6), [[tomcat6.0]](http://stackoverflow.com/questions/tagged/tomcat6.0)

**[[weblogic-8.x]](http://stackoverflow.com/questions/tagged/weblogic-8.x)**: [[weblogic8]](http://stackoverflow.com/questions/tagged/weblogic8), [[weblogic-8]](http://stackoverflow.com/questions/tagged/weblogic-8), [[weblogic8.1]](http://stackoverflow.com/questions/tagged/weblogic8.1), [[weblogic-8.1]](http://stackoverflow.com/questions/tagged/weblogic-8.1), [[weblogic8.x]](http://stackoverflow.com/questions/tagged/weblogic8.x)
**[[weblogic-9.x]](http://stackoverflow.com/questions/tagged/weblogic-9.x)**: [[weblogic9]](http://stackoverflow.com/questions/tagged/weblogic9), [[weblogic-9]](http://stackoverflow.com/questions/tagged/weblogic-9), [[weblogic9.x]](http://stackoverflow.com/questions/tagged/weblogic9.x)
**[[weblogic-10.x]](http://stackoverflow.com/questions/tagged/weblogic-10.x)**: [[weblogic10]](http://stackoverflow.com/questions/tagged/weblogic10),  [[weblogic-10]](http://stackoverflow.com/questions/tagged/weblogic-10), [[weblogic10.x]](http://stackoverflow.com/questions/tagged/weblogic10.x)
**[[weblogic-11g]](http://stackoverflow.com/questions/tagged/weblogic-11g)**: [[weblogic11]](http://stackoverflow.com/questions/tagged/weblogic11), [[weblogic-11]](http://stackoverflow.com/questions/tagged/weblogic-11), [[weblogic11g]](http://stackoverflow.com/questions/tagged/weblogic11g)


Create a new paste based on this one


Comments:
posted by RogerPate on May 20
reply