m********g 发帖数: 9 | 1 【 以下文字转载自 JobHunting 讨论区 】
发信人: mitliqiang (li qiang), 信区: JobHunting
标 题: An interview question for grep in linux
发信站: BBS 未名空间站 (Mon Jan 26 13:48:58 2009)
Using grep, identify the regular expression in a given string such that the
pattern does not repeat. For example, to identify the pattern 'foo' only
once in an input.
'jhkhfoojkkj' should be identified right
'kjhfooaaaaafoo' should not.
How to do that? I tested some, but can not succeed.
Thanks... | k*****h 发帖数: 33 | 2 grep -E ‘foo[^foo]+$’ filename
【 以下文字转载自 JobHunting 讨论区 】
发信人: mitliqiang (li qiang), 信区: JobHunting
标 题: An interview question for grep in linux
发信站: BBS 未名空间站 (Mon Jan 26 13:48:58 2009)
Using grep, identify the regular expression in a given string such that the
pattern does not repeat. For example, to identify the pattern 'foo' only
once in an input.
'jhkhfoojkkj' should be identified right
'kjhfooaaaaafoo' should not.
How to do that? I tested some, but can not succeed.
Thanks...
【在 m********g 的大作中提到】 : 【 以下文字转载自 JobHunting 讨论区 】 : 发信人: mitliqiang (li qiang), 信区: JobHunting : 标 题: An interview question for grep in linux : 发信站: BBS 未名空间站 (Mon Jan 26 13:48:58 2009) : Using grep, identify the regular expression in a given string such that the : pattern does not repeat. For example, to identify the pattern 'foo' only : once in an input. : 'jhkhfoojkkj' should be identified right : 'kjhfooaaaaafoo' should not. : How to do that? I tested some, but can not succeed.
| d****2 发帖数: 109 | |
|