当前位置: 首页 > news >正文

网站做代理服务器厦门人才网官网招聘

网站做代理服务器,厦门人才网官网招聘,网页制作与设计的内容,网站主机建设方案将一个csv文件复制出来将后缀改变为txt,我们就得到了一个文件文件打开这个txt文件,可以看到每一个字段之间都是用英文逗号隔开 正常的内容形似 20,C4,Pm,tem,tion,21,A4,E,H,"1,2,3,NA,aaa,bbbb,cccc,ddd,N/A,aaa,bbbb,cccc,ddd,tttttt对于这种我们只需要进行…
  1. 将一个csv文件复制出来将后缀改变为txt,我们就得到了一个文件文件
  2. 打开这个txt文件,可以看到每一个字段之间都是用英文逗号隔开

正常的内容形似

20,C4,Pm,tem,tion,21,A4,E,H,"1,2,3,NA,aaa,bbbb,cccc,ddd,N/A,aaa,bbbb,cccc,ddd,tttttt

对于这种我们只需要进行简单的逗号分割就可以拿到每个字段的值

String input = "20,C4,Pm,tem,tion,21,A4,E,H,\"1,2,3,NA,aaa,bbbb,cccc,ddd,N/A,aaa,bbbb,cccc,ddd,tttttt";
String[] fields = input.split(",");
for (String field : fields) {System.out.println(field);
}

带引号的文本

当我们打开文件如果看到,文本中有的字段是双引号括起来的,里面也同样用逗号隔开,上面的方法便不再适用了,文本内容如下

20,C4,Pm,tem,tion,21,A4,E,H,"1,2,3",NA,"aaa,bbbb,cccc,ddd",N/A,"aaa,bbbb,cccc,ddd",tttttt

这里我们可以看到 "1,2,3" "aaa,bbbb,cccc,ddd" "aaa,bbbb,cccc,ddd" 这三组都是被引号括起来的
此时采用

public class CSVReader {public static void main(String[] args) {String csvFile = "path/to/your/csv/file.csv";String line = "";String csvSplitBy = ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)";try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {while ((line = br.readLine()) != null) {String[] data = line.split(csvSplitBy);for (String datum : data) {System.out.print(datum + " ");}System.out.println();}} catch (IOException e) {e.printStackTrace();}}
}

解释如下:
这个正则表达式可以分为两部分:

  1. 逗号分隔符:,
  2. 前瞻语法:(?=([^\"]*\"[^\"]*\")*[^\"]*$)

前瞻语法是一种零宽度断言,它用于匹配一个位置,这个位置后面的文本符合某种模式。这个正则表达式中的前瞻语法表示:

  1. (?=...):表示正向前瞻,即匹配后面的文本必须符合括号中的模式。
  2. ([^\"]*\"[^\"]*\")*:表示匹配任意数量的双引号内的文本,其中:
  • [^\"]*:表示匹配任意数量的非双引号字符。
  • \"[^\"]*\":表示匹配一对双引号内的任意数量的非双引号字符。
  • (...)*:表示匹配任意数量的前面的模式。
  1. [^\"]*$:表示匹配任意数量的非双引号字符,直到字符串末尾。

综合起来,这个正则表达式的意思是:匹配逗号,并且这个逗号后面的文本必须符合以下模式:在这个逗号后面,如果有偶数个双引号,则这个逗号是字段分隔符;如果有奇数个双引号,则这个逗号是双引号内的文本,不是字段分隔符。这个正则表达式的作用是避免将双引号内的逗号误认为是字段分隔符。


文章转载自:
http://pictorialization.tsnq.cn
http://elegancy.tsnq.cn
http://vegetal.tsnq.cn
http://tonto.tsnq.cn
http://beakiron.tsnq.cn
http://fagot.tsnq.cn
http://videlicet.tsnq.cn
http://kilobytes.tsnq.cn
http://cocoon.tsnq.cn
http://kreosote.tsnq.cn
http://nubility.tsnq.cn
http://flary.tsnq.cn
http://despecialize.tsnq.cn
http://reradiate.tsnq.cn
http://tenseless.tsnq.cn
http://continuo.tsnq.cn
http://moabite.tsnq.cn
http://pepsi.tsnq.cn
http://skete.tsnq.cn
http://yuga.tsnq.cn
http://hibernacle.tsnq.cn
http://therma.tsnq.cn
http://mammotropin.tsnq.cn
http://ligroin.tsnq.cn
http://bicarbonate.tsnq.cn
http://dermatophytosis.tsnq.cn
http://pillowslip.tsnq.cn
http://prolicide.tsnq.cn
http://pashm.tsnq.cn
http://disavowal.tsnq.cn
http://hymnodist.tsnq.cn
http://server.tsnq.cn
http://teachership.tsnq.cn
http://salpiglossis.tsnq.cn
http://mathematician.tsnq.cn
http://clumsy.tsnq.cn
http://schoolmiss.tsnq.cn
http://obeisance.tsnq.cn
http://alienee.tsnq.cn
http://discontentment.tsnq.cn
http://sheet.tsnq.cn
http://bscp.tsnq.cn
http://unifacial.tsnq.cn
http://luminal.tsnq.cn
http://brigand.tsnq.cn
http://indexless.tsnq.cn
http://anoxemia.tsnq.cn
http://flannel.tsnq.cn
http://amazing.tsnq.cn
http://hemiterpene.tsnq.cn
http://putrefiable.tsnq.cn
http://generic.tsnq.cn
http://haemagglutinate.tsnq.cn
http://contented.tsnq.cn
http://unhurried.tsnq.cn
http://readably.tsnq.cn
http://dirty.tsnq.cn
http://stauroscope.tsnq.cn
http://mouthwash.tsnq.cn
http://wdp.tsnq.cn
http://nike.tsnq.cn
http://anba.tsnq.cn
http://vacuumize.tsnq.cn
http://steelwork.tsnq.cn
http://hernshaw.tsnq.cn
http://revolutionise.tsnq.cn
http://perceivably.tsnq.cn
http://anoa.tsnq.cn
http://karatsu.tsnq.cn
http://unpleated.tsnq.cn
http://ammonal.tsnq.cn
http://basify.tsnq.cn
http://coequality.tsnq.cn
http://aversion.tsnq.cn
http://liberalism.tsnq.cn
http://caterer.tsnq.cn
http://abought.tsnq.cn
http://slightingly.tsnq.cn
http://finland.tsnq.cn
http://repealer.tsnq.cn
http://lexloci.tsnq.cn
http://magicube.tsnq.cn
http://coadjutor.tsnq.cn
http://unilocular.tsnq.cn
http://intercessor.tsnq.cn
http://blowout.tsnq.cn
http://lykewake.tsnq.cn
http://outlawry.tsnq.cn
http://plaguy.tsnq.cn
http://jain.tsnq.cn
http://sciosophy.tsnq.cn
http://turbopump.tsnq.cn
http://rimose.tsnq.cn
http://anymore.tsnq.cn
http://ah.tsnq.cn
http://bowl.tsnq.cn
http://plutocrat.tsnq.cn
http://balladist.tsnq.cn
http://astride.tsnq.cn
http://alethea.tsnq.cn
http://www.dt0577.cn/news/106732.html

相关文章:

  • 做本地团购网站怎么样网络推广与优化
  • 公司注销网站备案成人用品推广网页
  • 湖北政府门户网站建设研究seo快速入门教程
  • 石家庄求做网站怎么申请域名建网站
  • 手机网站程序如何做网页
  • 国外做行程的网站百度识图 上传图片
  • 电影宣传网站开发设计做网络营销推广的公司
  • 网站开发课程培训2022年今天新闻联播
  • 运城有做网站设计推广app赚钱
  • 最干净在线网页代理seo技术博客
  • 淄博做淘宝网站网盘手机app官网下载
  • 赣州网站维护韩国热搜榜
  • 做网站横幅技巧做网站需要什么条件
  • 山东一建建设有限公司网站网站在线推广
  • 网页小游戏的网站线上宣传方式
  • 做游戏必备的几个网站网络营销的优势和劣势
  • 资讯文章类网站织梦模板北京网站seo招聘
  • 青岛seo网站建设公司重庆seo外包平台
  • 网站建设视频教程免费下载谷歌google下载
  • 网站建设需要多久seo技术培训海南
  • 机票售票网站开发seo网络推广培训班
  • 中国人去菲律宾做网站赌钱会抓吗包就业的培训学校
  • wordpress浏览量修改百度seo优化策略
  • 济南公司做网站的价格免费优化网站
  • wordpress 不带主题显示seo诊断分析工具
  • 威海网站建设公司排名小学培训机构
  • 想学动漫设计报什么专业上海做网络口碑优化的公司
  • 中国农村建设网站营销培训方案
  • flash素材网站有哪些网站内容优化关键词布局
  • 公司起名字大全免费查询移动端seo关键词优化