regex - 需要在 Notepad++ 中使用 REGEX 来查找包含空格的行中字符的长度
问题描述
我有一个 TEXT 文件,其中有 4700 行 30 个字符的值。数字字符位于 1 到 8 的位置,之后应该只有空格。我在 NOTEPAD++ 中使用 REGEX 来查找 2 个不同的场景:
- 我想查找在我的文本文件的任何行上是否存在位置 1-8 中小于 6 的字符长度。
- 我的文本文件中是否有长度 > 30 的行。我想我找到了答案,但想要一些确认,因为我没有在我的结果中找到任何东西。这是我在 NOTEPAD++ 中使用的找到这些值:.{30, }
任何帮助/方向将不胜感激。谢谢。
这是我的文件的示例:
332268-1
322335
322375
322393
322368-1
322381
322475
323912-1
322539
322641
322641
322514-1
322638
322978
322978
322638-1
287686
287735
322579
322643
323113
323257
331875
331875
322637-1
322720-1
322745-1
322679
322702
322971
324548
322971
333146-1
解决方案
1号将是^\d{0,5}\s+\n
^ matches the beginning of the string or line
\d digit
{0,5} matches quantify or proceeding token
\s whitespace
+ quantifier matches 1 or more
\n is a new line
2号将是^.{31,}
^ matches the beginning of the string or line
. matches any character but line breaks
{31,} matches any line that is 31 characters or greater.
推荐阅读
- ios - Flutter SelectableText 在iOS上没有全选选项
- python - 在 Python 中搜索一定长度的相同字符串
- java - 如何创建语言网页
- javascript - 本地函数在 Vue 中不起作用使用 useWebWorkerFn
- python - Python datetime strptime() 与格式不匹配
- php - 试图获取 laravel 有效负载的属性名称和 id
- javascript - 使用三元在地图内创建不同的对象
- flutter - 颤振垂直滑块
- reactjs - 物料表中的排序和分页无法正常工作
- winforms - 在 Visual Studio 2019 中创建设置项目时出现“错误:构建项目输出组的一般失败”