Re: How to use regex to search string between {}?

2019-08-28 Thread Sayth Renshaw
> > A site like http://www.pyregex.com/ allows you to check your regex with > slightly fewer clicks and keystrokes than editing your program. Thanks Jason -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use regex to search string between {}?

2019-08-28 Thread Jason Friedman
> > If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} > > import re > r = re.search('{.}', path) > # r should be ['h1,h2,h3,h4'] but I fail > > Why always search nothing? > A site like http://www.pyregex.com/ allows you to check your regex with slightly fewer clicks and keystrokes than editing

Re: How to use regex to search string between {}?

2019-08-23 Thread Chris Angelico
On Fri, Aug 23, 2019 at 6:44 PM lampahome wrote: > > I want to parse a path string with multiple files and try to figure out a > one-line way. > > If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} > > What I thought is use regex.search, but the pattern always failed. > > I use below: > import re

How to use regex to search string between {}?

2019-08-23 Thread lampahome
I want to parse a path string with multiple files and try to figure out a one-line way. If I have path: /home/admin/hello/yo/{h1,h2,h3,h4} What I thought is use regex.search, but the pattern always failed. I use below: import re path = /home/admin/hello/yo/{h1,h2,h3,h4} r = re.search('{.}',