I am trying to match a datatime inside square brackets and I thought prefixing "\" would be the way to encode square brackets but somehow it didn't work. Here is my code:
import re line_nginx = re.compile(r"""\[(?P<time_local>\S+) -700\]""", re.IGNORECASE) match = line_nginx.match("[07/Oct/2014:19:43:08 -0700]") if match: print("matched") else: print("no match")
I got "no match". Any idea what went wrong?
Python regex match square bracket issue
- 'Entry' object has no attribute 'set'
- How do I access text between tags with xml.etree.ElementTree
- RegeX code for PowerShell Lookbehind not working matching on IP Addressing
- How to groupby column name and join
- How to select context words/characters surrounding an <a> tag using BeautifulSoup?
- How to use operator.itemgetter to check a condition in a filter function instead of a lambda?
- How do I get the file / key size in boto S3?
- What does if __name__ == “__main__”: do?
- How to get String Before Last occurrence of substring?
- Is it possible to call the constructor of a class that inherits Enum without arguments?