Here is the regex - an egrep attempt and then Python 2.7:
$ echo '/some/path/to/file/abcde.csv' | egrep '* ([a-zA-Z] +). csv '
/ some / path / to / file / abcde.csv
However, the same regex in Python:
re.match(r'*([a-zA-Z]+)\.csv',f )
gives:
Traceback (most recent call last): File "/shared/OpenChai/bin/plothost.py", line 26, in <module> hosts = [re.match(r'*([a-zA-Z]+)\.csv',f ).group(1) for f in infiles] File "/usr/lib/python2.7/re.py", line 141, in match return _compile(pattern, flags).match(string) File "/usr/lib/python2.7/re.py", line 251, in _compile raise error, v
Performing a search shows that there is a Python error:
regular expression error - nothing will happen again
This seems to be a python bug (works fine in vim). The source of the problem is the bit (\ s * ...) +.
However, I do not understand: what is the workaround for my regex shown above to make python happy?
Thanks.
source share