在URL中的最后一个斜杠后替换所有内容

时间:2014-06-06 16:16:44

标签: regex openoffice-calc

我想使用正则表达式在开放式办公电子表格中进行搜索/替换。

我需要在最后一个正斜杠后面的URL列表中插入一个身份验证组件。

我试了[/]$(\/)$而没有运气。

示例输入:https://testdomain.com/dir1/file.pdf

所需的输出:https://testdomain.com/dir1/authcode123file.pdf

2 个答案:

答案 0 :(得分:0)

我不确定你的程序,但是这样的事情怎么样:

enter image description here

答案 1 :(得分:0)

试试这个:

搜索(.*/)(.*)$

替换为 :: $1authcode123$2

说明:

 (.*)       -  Anything inside two parens "()" is called a capture
               group.  The text that matches the pattern inside the
               first set of parens is stored in "capture group 1".
               You can use $1 to refer to this capture group when
               you do your replace.  Likewise $2 will refer to the
               second capture group.

  .         -  A period represents ANY CHARACTER.

  .*        -  The asterisk "*" means "zero of more of the precedding
               pattern."  So .* would mean "zero or more occurrences
               of ANY CHARACTER." 

 (.*/)    -  zero or more characters followed by a slash 
              (the results of this capture are stored in $1)

 (.*)$    -  zero or more chars followed by the end of the string 
              (the results of this capture are stored in $2)

Screenshot

但是,您尚未分享所有要求的详细信息,因此我不知道此答案是否完整。

例如,你会对没有斜杠的网址做些什么?