This regex works in pythex, but not in python 3.6.  I am not sure why:    Code in python:  import re test = '105297  003  002394  o  0000  20891  0.00  1' pattern = r"(?P&lt;pun1&gt;\d{3})\s+(?P&lt;pun2&gt;\d{6})(\s+(?P&lt;pun3&gt;[01oO])(\s+(?P&lt;pun4&gt;\d{4}))?)?\s.*\s(?P&lt;amt&gt;\d+\.\d\d)\s" match = re.match(pattern, test, re.IGNORECASE) match is None True   I haven't been able to figure out why it works in pythex but not in python interpreter.
372
What is the difference between the search() and match() functions in the ?  I've read the  (), but I never seem to remember it.  I keep having to look it up and re-learn it.  I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.  Or at least I'll have a better place to return with my question and it will take less time to re-learn it.
59657
Regex.IsMatch( "foo", "[\U00010000-\U0010FFFF]" )    Throws: System.ArgumentException: parsing "[-]" - [x-y] range in reverse order.  Looking at the hex values for \U00010000 and \U0010FFF I get: 0xd800 0xdc00 for the  first character and 0xdbff 0xdfff for the second.  So I guess I have really have one problem. Why are the Unicode characters formed with \U split into two chars in the string?
111187
If I'm trying to match a quote-delimited string with a regex, which of the following is "better" (where "better" means both more efficient and less likely to do something unexpected):  /"[^"]+"/ # match quote, then everything that's not a quote, then a quote   or  /".+?"/   # match quote, then *anything* (non-greedy), then a quote   Assume for this question that empty strings (i.e. "") are not an issue. It seems to me (no regex newbie, but certainly no expert) that these will be equivalent.   Update: Upon reflection, I think changing the + characters to * will handle empty strings correctly anyway.
49733
I am currently defining regular expressions in order to capture parameters in a URL, as described in the tutorial. How do I access parameters from the URL as part the HttpRequest object? My HttpRequest.GET currently returns an empty QueryDict object. I'd like to learn how to do this without a library, so I can get to know Django better.
83873
Is it possible to do something like this?  var pattern = /some regex segment/ + /* comment here */     /another segment/;   Or do I have to use new RegExp() syntax and concatenate a string? I'd prefer to use the literal as the code is both more self-evident and concise.
123924
I'm trying to match a string pattern to any string in an array:  SELECT 'abc' LIKE ANY('{"abc","def"}') -- TRUE  -- BUT  SELECT 'ab%' LIKE ANY('{"abc","def"}') -- FALSE, I expect TRUE   What is wrong with the second query?
118631
A friend asked me this and I was stumped: Is there a way to craft a regular expression that matches a sequence of the same character? E.g.,  match on 'aaa', 'bbb', but not 'abc'?  m|\w{2,3}|    Wouldn't do the trick as it would match 'abc'.  m|a{2,3}|    Wouldn't do the trick as it wouldn't match 'bbb', 'ccc', etc.
92922
I'm having trouble writing a regular expression that matches valid IPv6 addresses, including those in their compressed form (with :: or leading zeros omitted from each byte pair).    Can someone suggest a regular expression that would fulfill the requirement?  I'm considering expanding each byte pair and matching the result with a simpler regex.
103438
I use to run  $s =~ s/[^[:print:]]//g;   on Perl to get rid of non printable characters.   In Python there's no POSIX regex classes, and I can't write [:print:] having it mean what I want. I know of no way in Python to detect if a character is printable or not.   What would you do?   EDIT: It has to support Unicode characters as well. The string.printable way will happily strip them out of the output.  curses.ascii.isprint will return false for any unicode character.
48554
I've noticed that, if I add \n to a pattern for substituting using sed, it does not match. Example:  $ cat &gt; alpha.txt This is a test Please do not be alarmed  $ sed -i'.original' 's/a test\nPlease do not/not a test\nBe/' alpha.txt  $ diff alpha.txt{,.original}  $ # No differences printed out   How can I get this to work?
46901
In Python, I can compile a regular expression to be case-insensitive using re.compile:  &gt;&gt;&gt; s = 'TeSt' &gt;&gt;&gt; casesensitive = re.compile('test') &gt;&gt;&gt; ignorecase = re.compile('test', re.IGNORECASE) &gt;&gt;&gt;  &gt;&gt;&gt; print casesensitive.match(s) None &gt;&gt;&gt; print ignorecase.match(s) &lt;_sre.SRE_Match object at 0x02F0B608&gt;   Is there a way to do the same, but without using re.compile. I can't find anything like Perl's i suffix (e.g. m/test/i) in the documentation.
33951
Im trying to craft a regex that only returns &lt;link&gt; tag hrefs  Why does this regex return all hrefs including &lt;a hrefs?       (?&lt;=&lt;link\s+.*?)href\s*=\s*[\'\"][^\'\"]+        &lt;link rel="stylesheet" rev="stylesheet"      href="idlecore-tidied.css?T_2_5_0_228" media="screen">     &lt;a href="anotherurl">Slash Boxes&lt;/a>   thank you
39933
How can I get the start and end positions of all matches using the re module? For example given the pattern r'[a-z]' and the string 'a1b2c3d4' I'd want to get the positions where it finds each letter. Ideally, I'd like to get the text of the match back too.
3017
I wrote a regular expression which works well in a certain program (grep, sed, awk, perl, python, ruby, ksh, bash, zsh, find, emacs, vi, vim, gedit, …). But when I use it in a different program (or on a different unix variant), it stops matching. Why?
40669
I want to reverse a regular expression. I.e. given a regular expression, I want to produce any string that will match that regex.  I know how to do this from a theoretical computer science background using a finite state machine, but I just want to know if someone has already written a library to do this. :)  I'm using Python, so I'd like a Python library.  To reiterate, I only want one string that will match the regex. Things like "." or ".*" would make an infinite amount of strings match the regex, but I don't care about all options.  I'm willing for this library to only work on a certain subset of regex.
3909
Is there a way to achieve the equivalent of a  in javascript regular expressions?  I need to match a string that does not start with a specific set of characters.  It seems I am unable to find a regex that does this without failing if the matched part is found at the beginning of the string.  Negative lookbehinds seem to be the only answer, but javascript doesn't have one.  EDIT: This is the regex that I would like to work, but it doesn't:  (?&lt;!([abcdefg]))m  So it would match the 'm' in 'jim' or 'm', but not 'jam'
52153
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example), grabs the episode name (from the www.thetvdb.com API) and automatically renames them into something nicer (Show Name - [01x02].avi)  The script works fine, that is until you try and use it on files that have Unicode show-names (something I never really thought about, since all the files I have are English, so mostly pretty-much all fall within [a-zA-Z0-9'\-])  How can I allow the regular expressions to match accented characters and the likes? Currently the regex's config section looks like..  config['valid_filename_chars'] = """0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@£$%^&amp;*()_+=-[]{}"'.,&lt;&gt;`~? """ config['valid_filename_chars_regex'] = re.escape(config['valid_filename_chars'])  config['name_parse'] = [     # foo_[s01]_[e01]     re.compile('''^([%s]+?)[ \._\-]\[[Ss]([0-9]+?)\]_\[[Ee]([0-9]+?)\]?[^\\/]*$'''% (config['valid_filename_chars_regex'])),     # foo.1x09*     re.compile('''^([%s]+?)[ \._\-]\[?([0-9]+)x([0-9]+)[^\\/]*$''' % (config['valid_filename_chars_regex'])),     # foo.s01.e01, foo.s01_e01     re.compile('''^([%s]+?)[ \._\-][Ss]([0-9]+)[\.\- ]?[Ee]([0-9]+)[^\\/]*$''' % (config['valid_filename_chars_regex'])),     # foo.103*     re.compile('''^([%s]+)[ \._\-]([0-9]{1})([0-9]{2})[\._ -][^\\/]*$''' % (config['valid_filename_chars_regex'])),     # foo.0103*     re.compile('''^([%s]+)[ \._\-]([0-9]{2})([0-9]{2,3})[\._ -][^\\/]*$''' % (config['valid_filename_chars_regex'])), ]