命理的条文在古书里面都是pdf,要自己一个个手敲,还好有了网络很多工作有人已经做了。但是直接复制下来没有什么作用,因为一条断语往往包含了多条规则,有的还包含了几个方面的断言,这个时候就使用到爬虫+ 正则表达式 来处理了。这里用到了一个在线验证正则的网站https://regex101.com/ 1 提 中间 字段 下面代码中(?<=(:))是匹配:开头的字符串,而(?=(生人))则匹配以生人为结尾的字符串,参考正则 ?<= 和 ?= 用法 def parse_content(content): 例子如下: public String getPattern(String str,String pattern){ Pattern compile = Pattern.compile("(?<=\""+pattern+"\":\").*?(?=\")", Pattern.CASE_INSENSITIVE); Matcher matc 使用 正则表达式 html标签 中间 内容 ,如:abc<span>def</span>gh<font>666</font>999 代码如下: public static void main(String[] args) { String s = "abc<span>def</span>gh<fon...