Maggie Q Roth <rot...@gmail.com> writes: > There are two primary types of lines in the log: > > 60.191.38.xx / > 42.120.161.xx /archives/1005 > > I know how to write regex to match each line, but don't get the good result > with one regex to match both lines. > > Can you help?
When I look at these lines, I see 2 fields separated by whitespace (note that two example lines are very very few to guess the proper pattern). I would not use a regular expression in this case, but the `split` string method. A regular expression for this pattern could be `(\S+)\s+(.*)` which reads a non-empty sequences of none whitespace (assigned to group 1), whitespace, any sequence (assigned to group 2) (note that the regular expression above is given on the regex level. The string in your Python code may look slightly different). -- https://mail.python.org/mailman/listinfo/python-list