diff --git a/src/library/tools/R/Rd2HTML.R b/src/library/tools/R/Rd2HTML.R
index 2ee5df5ea7..ab09097fd5 100644
--- a/src/library/tools/R/Rd2HTML.R
+++ b/src/library/tools/R/Rd2HTML.R
@@ -1455,7 +1455,7 @@ function(dir)
if(a) {
## URL regexp as in .DESCRIPTION_to_latex(). CRAN uses
## <(URL: *)?((https?|ftp)://[^[:space:]]+)[[:space:]]*>
- ## ([^>\"?])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])
+ ## ([[:space:]])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])
## (also used in toRd.citation().
x <- trfm("<(http://|ftp://|https://)([^[:space:],>]+)>",
"\\1\\2",
diff --git a/src/library/tools/R/toHTML.R b/src/library/tools/R/toHTML.R
index d75a3aff36..11affb49b5 100644
--- a/src/library/tools/R/toHTML.R
+++ b/src/library/tools/R/toHTML.R
@@ -342,7 +342,7 @@ function(x, header = TRUE, ...)
## Need to ignore results of the above translation ...
## Regexp based on Perl HTML::TextToHTML, note that the dash
## must be last ...
- s <- .gsub_with_transformed_matches("([^>\"?])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])",
+ s <- .gsub_with_transformed_matches("([[:space:]])((https?|ftp)://[[:alnum:]/.:@+\\_~%#?=&;,-]+[[:alnum:]/])",
"\\1\\2",
s,
urlify,