doumen6605 2014-10-08 04:53
浏览 160
已采纳

正则表达式//服务器名称或IP地址/ Sharedfolder /路径/到/保存/文件

I found this

^\/(\/[^\s\/]+)+(\/)?$

But it matches right after the double forward slashes and any character

I need it to match to at least //servernameoripaddress/shareddir and it can go on from there ie. //Server Name or IP Address/Sharedfolder/Path/to/Saved/Files

Thank you all, I would appreciate any help for this.

  • 写回答

1条回答 默认 最新

  • duanjuete9206 2014-10-08 06:06
    关注

    Based on Regular expression to match DNS hostname or IP Address?:

    ^//(?:(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))(?:/[^/]+)+$
    

    Demo.

    Explanation:

    ^// # make sure the string starts with two slashes
    (?: # match an IP address...
        (([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
    | #... or a host name
        (([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])
    )
    (?:
        /[^/]+ # match a slash, followed by at least one character...
    )+ #... at least once
    $ # and make sure the string ends here
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料