Android上的有效目录名 [英] Valid Directoryname on Android

查看:147
本文介绍了Android上的有效目录名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了正则表达式来检查新目录的名称之前,我在文件系统上创建。
例如是/不是在目录的名称允许的。
我在正则表达式没有经验,因此任何帮助是值得欢迎的。


解决方案

  \\\\ W +


  • \\ w被equilvalent为[A-ZA-Z0-9 _]

  • +将匹配一个或多个字符

这里的文档。

修改

  Log.e(TAG,的HelloWorld+HelloWorld的\\\\匹配((\\\\ W +)));

最后一个给我返回false。

I search for a regex pattern to check the name of a new directory before i create it on the file system. For example is "/" not allowed in the name of a directory. I have no experience in regex so any help is welcome.

解决方案

\\w+

  • \w is equilvalent to [A-Za-z0-9_]
  • "+" will match one or more chars

To

here the documentation.

Edit

  Log.e("TAG", "Helloworld " + "helloworld\\".matches(("\\w+")));

last one returned false for me.

这篇关于Android上的有效目录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆