Is this PCRE regex convertible by pcre2el to Emacs syntax?
\[\[[^\s\/]+:\/*(\/[^]]*)\]*\[[^]]*\]\]
The result of the conversion is [ /[^]+:/*\(/[^]]*\)]*[[^]]*]] and
when I apply it in a query-replace-regexp command it doesn't work.
#+begin_src emacs-lisp
(pcre-to-elisp "\[\[[^\s\/]+:\/*(\/[^]]*)\]*\[[^]]*\]\]")
#+end_src
#+RESULTS:
: [ /[^]+:/*\(/[^]]*\)]*[[^]]*]]
I am not sure whether some additional processing is needed on the original PCRE string before applying it to the pcre-to-elisp function, or it is a string pcre-to-elisp is unable to translate.
The regex is an answer I got from the r/regex subreddit. Answer to : Regex to reduce repeated instances of a character to a set number (usually 1)
Here is the question fully reproduced below.
This is an example of an org-mode link
[[file:/abc/def/ghi][Abc Def Ghi]]
I've found myself with a file (actually my own doing) where some of the lines have multiple slashes after the url type, eg.
[[file://////abc/def/ghi][Abc Def Ghi]]
I need a regex that can extract the actual link. I have succeeded partially but I want to do it one go as it will be used in a script.
So applying the regex to [[file://////abc/def/ghi][Abc Def Ghi]] should result in /abd/def/ghi.
I have come up with \[\[\([a-z0-9_/.]*\)\].* -> \1, but I need something more to strip the url type and the superflous forward slashes, ie all but the last one.