4

So I'm looking for a pattern like this:

size='0x0'

In a log file, but I'm only interested in large sizes (4 digits or more). The following regex works great in EditPadPro (nice tool BTW)

size='0x[0-9a-fA-F]{4,}

But the same RegEx does not work in awk - seems like the repetition {4,} is messing it up. Same with WinGrep - any idea from the RegEx gurus? Thanks!

4

3 回答 3

5

You can in fact use awk, with a caveat.

As mentioned on the following page, you need a special command-line option (--re-interval) to make it work out, since the interval expression (the {4,}) is not in the standard:

http://kansai.anesth.or.jp/gijutu/awk/gawk/gawk_28.html

So in the end, you'll want something that looks like:

awk --re-interval "/size='0x[0-9a-fA-F]{4,}'/" thefile

This will print out the lines that match.

于 2008-11-06T20:22:20.597 回答
4

I don't know of any elegant alternatives to the {4,} syntax, but if it is not working in your desired environment you could resort to this ugly hack:

size='0x[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]+

Hope this helps!

Adam

于 2008-11-06T19:01:44.800 回答
0

Don't forget the last apostrophe.

'
于 2008-11-06T19:52:31.203 回答