How to use regex to search string between {}?

Jason Friedman jsf80238 at gmail.com
Wed Aug 28 23:21:01 EDT 2019


>
> 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 your program.



More information about the Python-list mailing list