Posts

Showing posts with the label pcre

Perl compatible regular expression (PCRE) in Python

Perl compatible regular expression (PCRE) in Python I have to parse some strings based on PCRE in Python, and I've no idea how to do that. Strings I want to parse looks like: match mysql m/^.n(4.[-.w]+).../s p/MySQL/ i/$1/ In this example, I have to get this different items: "m/^.n(4.[-.w]+).../s" ; "p/MySQL/" ; "i/$1/" The only thing I've found relating to PCRE manipulation in Python is this module: http://pydoc.org/2.2.3/pcre.html (but it's written it's a .so file ...) Do you know if some Python module exists to parse this kind of string? Just to be clear: You want to match PCREs, not use them? – Tim Pietzcker Aug 15 '11 at 9:37 I have to use them – Steeve Aug 15 '11 at 9:41 ...

listing all ipv4 addresses from LOG using PCRE regex

listing all ipv4 addresses from LOG using PCRE regex I need to write a regular expression which will list all ip addresses from logs. The addresses should have different groups, so it should not match only to full match. The amount of ip addresses is not constant. The log looks like this <177>Jun 28 15:35:15 src=192.168.100.122 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Null scan (attempts with response: 144, attempts without response: 0, targets: 56, port(s): 443, 80, 5274, 445, 88, 4120, 135, 49155). targetList: 12.97.135.114, 18.232.35.16, 10.10.202.7, 10.101.90.178, 30.101.124.18, 13.107.3.128, 10.83.127.51, 12.160.91.170, 10.101.124.34, 10.10.200.12 <177>Jun 28 15:35:15 src=192.168.100.122 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Null scan (attempts with response: 144, attempts without response: 0, targets: 56, port(s): 443, 80, 5274, 445, 88, 4120, 135, 49155). targetList: 12.97.135.114, 18.232.35.16, 10.10.202.7, 10...