Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将字母数字与下面的正则表达式匹配,但仍然匹配我不需要的结果。
([0-9a-z_]+|[0-9a-z]+)
我真正想要匹配的是
Example: abc123 abc_123
我不想匹配的是
Example: abc 123 123_123 abc_abc
perl解决方案怎么样
> cat alphanum.txt abc123 abc_123 abc 123 123_123 abc_abc > perl -ne ' { print if /\b([a-z]+)|_\b/ and /([0-9]+)/ }' alphanum.txt abc123 abc_123 >
试试这是否适合你。