no need for incomplete or unreliable hacks. there’s a function included with python for this
>>> import fnmatch
>>> fnmatch.translate( '*.foo' )
'.*\\.foo$'
>>> fnmatch.translate( '[a-z]*.txt' )
'[a-z].*\\.txt$'
More Related Contents:
- Regular expressions in a Bash case statement
- What are the differences between glob-style patterns and regular expressions?
- Regex Until But Not Including
- Regular Expression usage with ls
- What’s the best tool to find and replace regular expressions over multiple files?
- Regex for PascalCased words (aka camelCased with leading uppercase letter)
- How does the () and [] come into play with regex?
- What is this pattern “\\s*\\^++\\s*” used for? [duplicate]
- How do (*SKIP) or (*F) work on regex?
- Regular Expression to find a string included between two characters while EXCLUDING the delimiters
- Difference between * and + regex
- Regex to validate JSON
- Regex to match only letters
- How to calculate the number of occurrence of a given character in each row of a column of strings?
- Regular expression to enforce complex passwords, matching 3 out of 4 rules
- Regular expression for a string that does not start with a sequence
- How can I use a variable in the replacement side of the Perl substitution operator?
- Regex to match all permutations of {1,2,3,4} without repetition
- Negate characters in Regular Expression [closed]
- Why is sed not recognizing \t as a tab?
- Symbol for any number of any characters in regex?
- JSLint reports “Insecure ^” for my regex — what does that mean?
- Insert linefeed in sed (Mac OS X)
- What is a Context Free Grammar?
- How do I check if a filename matches a wildcard pattern
- Implement auto-complete feature using MongoDB search
- What’s the regex to match anything except a double quote not preceded by a backslash?
- Why do regex engines allow / automatically attempt matching at the end of the input string?
- How do I turn any regex into an complement of itself without complex hand editing?
- Apache mod_rewrite REDIRECT_STATUS condition causing directory listing