用haclon程序将目录名分离的算法。

ParseFileName:='F:/D705/4-20/缺陷/81.bmp'

parse_filename(ParseFileName, BaseName, Extension, Directory)

* This procedure gets a filename (with full path) as input
* and returns the directory path, the base filename and the extension
* in three different strings.
*
* In the output path the path separators will be replaced
* by '/' in all cases.
*
* The procedure shows the possibilities of regular expressions in HALCON.
*
* Input parameters:
* FileName: The input filename
*
* Output parameters:
* BaseName: The filename without directory description and file extension
* Extension: The file extension
* Directory: The directory path
*
* Example:
* basename('C:/images/part_01.png',...) returns
* BaseName = 'part_01'
* Extension = 'png'
* Directory = 'C:\\images\\' (on Windows systems)
*
* Explanation of the regular expressions:
*
* '([^\\\\/]*?)(?:\\.[^.]*)?$':
* To start at the end, the '$' matches the end of the string,
* so it is best to read the expression from right to left.
* The part in brackets (?:\\.[^.}*) denotes a non-capturing group.
* That means, that this part is matched, but not captured
* in contrast to the first bracketed group ([^\\\\/], see below.)
* \\.[^.]* matches a dot '.' followed by as many non-dots as possible.
* So (?:\\.[^.]*)? matches the file extension, if any.
* The '?' at the end assures, that even if no extension exists,
* a correct match is returned.
* The first part in brackets ([^\\\\/]*?) is a capture group,
* which means, that if a match is found, only the part in
* brackets is returned as a result.
* Because both HDevelop strings and regular expressions need a '\\'
* to describe a backslash, inside regular expressions within HDevelop
* a backslash has to be written as '\\\\'.
* [^\\\\/] matches any character but a slash or backslash ('\\' in HDevelop)
* [^\\\\/]*? matches a string od ..n characters (except '/' or '\\')
* where the '?' after the '*' switches the greediness off,
* that means, that the shortest possible match is returned.
* This option is necessary to cut off the extension
* but only if (?:\\.[^.]*)? is able to match one.
* To summarize, the regular expression matches that part of
* the input string, that follows after the last '/' or '\\' and
* cuts off the extension (if any) after the last '.'.
*
* '\\.([^.]*)$':
* This matches everything after the last '.' of the input string.
* Because ([^.]) is a capturing group,
* only the part after the dot is returned.
*
* '.*[\\\\/]':
* This matches the longest substring with a '/' or a '\\' at the end.
*
tuple_regexp_match (FileName, '.*[\\\\/]', DirectoryTmp)
tuple_substr (FileName, strlen(DirectoryTmp), strlen(FileName) - , Substring)
tuple_regexp_match (Substring, '([^\\\\/]*?)(?:\\.[^.]*)?$', BaseName)
tuple_regexp_match (Substring, '\\.([^.]*)$', Extension)
*
*
* Finally all found backslashes ('\\') are converted
* to a slash to get consistent paths
tuple_regexp_replace (DirectoryTmp, ['\\\\','replace_all'], '/', Directory)
return ()

halcon分离路径名称的更多相关文章

  1. python获取某路径下,某种特定类型的文件名称,os.walk(路径)生成器;os.listdir(路径),os.path.splitext(名称),os.path.join(路径,名称),os.path.isdir(路径\名称)

    #获取某文件夹下制定类型文件# import os# def filep(fp):# l=[]# a=os.walk(fp) #生成器# for nowp,sonp,oth in a: #当前目录,子 ...

  2. Foxpro数据库连接错误解决方法--【VFP DBF文件不是一个有效的路径。 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器】

    直接访问vfp dbf文件时报错: 错误描述: 'd:\vfpData\test.dbf'不是一个有效的路径. 确定路径名称拼写是否正确,以及是否连接到文件存放的服务器. 解决办法:Data Sour ...

  3. 【转】如何解决Ubuntu终端里面显示路径名称太长

    原文网址:http://jingyan.baidu.com/article/3d69c5516c129df0ce02d77b.html Ubuntu 默认的终端下面,进入很多层的目录后,前面那个提示符 ...

  4. Python根据路径名称获取文件的名称以及所在的路径

    大神一看题目就知道用python中的string.split('\'),记得之前处理大量的文件的时候,有时候有几十万的文本文件,经常会读取获取名称,并且保存为名字一样的另外一种格式的文件 其实pyth ...

  5. 解决Ubuntu终端里面显示路径名称太长

    方法/步骤 找到配置文件先进行备份:  cp  ~/.bashrc  ~/.bashrc-bak 找到配置文件修改: vi  ~/.bashrc 备份是为了防止配置修改出错,可以还原: 下面是我的/h ...

  6. Ubuntu终端里面显示路径名称太长,怎么设置变短【转】

    转自:http://blog.csdn.net/id19870510/article/details/8276914 $: sudo vi ~/.bashrc 这个文件记录了用户终端配置 找到 if ...

  7. glob - 形成路径名称

    描述 (DESCRIPTION) 很久以前 在 UNIX V6 版 中 有一个 程序 /etc/glob 用来 展开 通配符模板. 不久以后 它 成为 shell 内建功能. 现在 人们 开发了 类似 ...

  8. 根据ID和parentID利用Java递归获取全路径名称

    如下图所示,本文参考资源:https://jie-bosshr.iteye.com/blog/1996607  感谢大佬的无私奉献. 思路: 定义一个方法getParentName参数为int类型的c ...

  9. 获取driver网络路径名称

    'get the web path of the drive s: Dim MM As New Management.ManagementObject(String.Format("win3 ...

随机推荐

  1. Alpha冲刺6

    前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/10004107.html 作业博客:https://edu.cnblogs.com/campus ...

  2. cut语法2

    linux每日一命令--cut--按文件大小排序 显示前100行 显示后五列 ll -Sh|head -n 100|cut -d ' ' -f 5- 一.基本语法cut是一个选取命令,以行为单位,用指 ...

  3. scrapy中crawlspide中callback和follow函数的作用及使用方法

    Rule(LinkExtractor(allow=r'i/tems'),callback='parse_item',follow=True)  当前代码的含义就是将当前页面及按照allow=r'i/t ...

  4. 实验楼高级bash脚本编程指南 挑战:简单的热身

    传送门:https://www.shiyanlou.com/courses/running# 步骤一 新建一个 test.sh 输出 Hello Shiyanlou! 步骤二 复制 test.sh 为 ...

  5. # 20175120 2018.3.3 《Java程序设计》第1周学习总结

    ## 教材学习内容总结 1.安装ubuntu,在实验楼学习liunx系统各种功能的实现.2.在ubuntu平台上进行java程序的编写3.学会使用JDB调试java程序,并将代码上传到码云上4.学习j ...

  6. python入门第二天

    啦啦啦啦啦!!!!我又来啦,几天该正式开始学习python语言啦,好高兴啊!!!今天学习的主要内容是变量和简单的数据类型!! 变量和简单的数据类型 大家回忆一下昨天的Hello Python Worl ...

  7. mingw using pthread

    转载http://www.cnblogs.com/tfanalysis/p/5505163.html ftp://sourceware.org/pub/pthreads-win32/ 有的时候需要使用 ...

  8. IDEA整合Junit测试框架

    首先说一下为什么会有这篇文章吧,百度没有找到一个我想要的答案.也可以理解为,作为一个java菜鸟,一个对idea和jar理解不深的人,想跟着博客一步步操作完之后发现,哎不行,之后的牢骚吧.主要是为了记 ...

  9. Spring Cloud(Dalston.SR5)--Config 集群配置中心

    Spring Cloud Config 是一个全新的项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持,他分为服务端和客户端两个部分.服务端也称为分布式配置中心,是一个独立的微服务 ...

  10. 一次完整的HTTP事务是怎样一个过程?(转)

    HTTP协议 关于HTTP协议可以参考以下: HTTP协议漫谈 http://kb.cnblogs.com/page/140611/ HTTP协议概览 http://www.cnblogs.com/v ...