试图找到小写字符的正则表达式匹配,但忽略前11个字符

时间:2022-10-07 21:52:21

I've got a file with text like this...

我有一个这样的文件文件......

0x8a1d4099 dfg-gw2
0x8da88e90 FVG-GW3

I want to write a bash script to look at the file, but only display the first line, not the second. I simply need to ignore the first 11 characters, and only match on the text that follows if it has lowercase characters.

我想编写一个bash脚本来查看该文件,但只显示第一行而不是第二行。我只需要忽略前11个字符,只有匹配后面的文本,如果它有小写字符。

Can you help?

你能帮我吗?

2 个解决方案

#1


1  

try

^.{11}[^a-z]*[a-z]+

conceptually, this pattern skips 11 characters at the beginning of a line, matches an arbitrary number of non-lowercase characters finally matching at least 1 lowercase char. complement the first chracter class with characters you do not want to occur in matching line.

从概念上讲,此模式在一行的开头跳过11个字符,匹配最终匹配至少1个小写字符的任意数量的非小写字符。使用您不希望在匹配行中出现的字符补充第一个chracter类。

#2


0  

A pattern like this should work:

像这样的模式应该工作:

^.{11,}[a-z].*$

Or if your engine supports Unicode character classes:

或者,如果您的引擎支持Unicode字符类:

^.{11,}\p{Ll}.*$

Alternatively, if your engine supports lookaheads, you can use one of these:

或者,如果您的引擎支持前瞻,您可以使用以下方法之一:

^.{11}(?=.*[a-z]).*$
^.{11}(?=.*\p{Ll}).*$

#1


1  

try

^.{11}[^a-z]*[a-z]+

conceptually, this pattern skips 11 characters at the beginning of a line, matches an arbitrary number of non-lowercase characters finally matching at least 1 lowercase char. complement the first chracter class with characters you do not want to occur in matching line.

从概念上讲,此模式在一行的开头跳过11个字符,匹配最终匹配至少1个小写字符的任意数量的非小写字符。使用您不希望在匹配行中出现的字符补充第一个chracter类。

#2


0  

A pattern like this should work:

像这样的模式应该工作:

^.{11,}[a-z].*$

Or if your engine supports Unicode character classes:

或者,如果您的引擎支持Unicode字符类:

^.{11,}\p{Ll}.*$

Alternatively, if your engine supports lookaheads, you can use one of these:

或者,如果您的引擎支持前瞻,您可以使用以下方法之一:

^.{11}(?=.*[a-z]).*$
^.{11}(?=.*\p{Ll}).*$