Make queryStringToLabel more useful

Change-Id: I381255725f095e1a2c7e53eb51d99cc37f2066a1
diff --git a/R/misc.R b/R/misc.R
index 9327a32..19ee92c 100644
--- a/R/misc.R
+++ b/R/misc.R
@@ -50,6 +50,8 @@
 #' by clipping off prefixes and suffixes that are common to all query strings.
 #'
 #' @param data string or vector of query or vc definition strings
+#' @param pubDateOnly discard all but the publication date
+#' @param excludePubDate discard publication date constraints
 #' @return string or vector of strings with clipped off common prefixes and suffixes
 #'
 #' @examples
@@ -61,13 +63,18 @@
 #' @importFrom PTXQC lcsCount
 #'
 #' @export
-queryStringToLabel <- function(data) {
+queryStringToLabel <- function(data, pubDateOnly = F, excludePubDate = F) {
+  if (pubDateOnly) {
+    data <-substring(data, regexpr("pubDate", data)+7)
+  } else if(excludePubDate) {
+    data <-substring(data, 1, regexpr("pubDate", data))
+  }
   leftCommon = lcpCount(data)
-  while (leftCommon > 0 && grepl("[[:alnum:]]", substring(data[1], leftCommon, leftCommon))) {
+  while (leftCommon > 0 && grepl("[[:alnum:]/=.*!]", substring(data[1], leftCommon, leftCommon))) {
     leftCommon <- leftCommon - 1
   }
   rightCommon = lcsCount(data)
-  while (rightCommon > 0 && grepl("[[:alnum:]]", substring(data[1], rightCommon, rightCommon))) {
+  while (rightCommon > 0 && grepl("[[:alnum:]/=.*!]", substring(data[1], 1+nchar(data[1]) - rightCommon, 1+nchar(data[1]) - rightCommon))) {
     rightCommon <- rightCommon - 1
   }
   substring(data, leftCommon + 1, nchar(data) - rightCommon)
diff --git a/man/queryStringToLabel.Rd b/man/queryStringToLabel.Rd
index 2381651..67d138c 100644
--- a/man/queryStringToLabel.Rd
+++ b/man/queryStringToLabel.Rd
@@ -4,10 +4,14 @@
 \alias{queryStringToLabel}
 \title{Convert query or vc strings to plot labels}
 \usage{
-queryStringToLabel(data)
+queryStringToLabel(data, pubDateOnly = F, excludePubDate = F)
 }
 \arguments{
 \item{data}{string or vector of query or vc definition strings}
+
+\item{pubDateOnly}{discard all but the publication date}
+
+\item{excludePubDate}{discard publication date constraints}
 }
 \value{
 string or vector of strings with clipped off common prefixes and suffixes