This is pretty simple but I can't seem to figure this one out. What am I doing wrong here?  The online tester shows this works fine:   But I am getting nothing returned when I try it in the Python REPL:  test = """&lt;speak&gt;&lt;prosody volume=\"x-loud\"&gt;This text should match?&lt;break time='500ms'/&gt;&lt;mark name='punchline'/&gt;\n\n&lt;say-as interpret-as='interjection'&gt;boing&lt;/say-as&gt;&lt;break time='1ms'/&gt;!\n&lt;/prosody&gt;&lt;/speak&gt;""" rex = '(?&lt;=&lt;speak&gt;&lt;prosody volume=\\\"x-loud\\\"&gt;)(.*)(?=&lt;\/prosody&gt;(?:&lt;metadata&gt;|&lt;\/speak&gt;))' m = re.search(rex,test)
4355
For example, this regex  (.*)&lt;FooBar&gt;   will match:  abcde&lt;FooBar&gt;   But how do I get it to match across multiple lines?  abcde fghij&lt;FooBar&gt;
28013
Please consider the following MWE - where I try to test for string equality between an parameter, and a test string prepared by a macro:  \documentclass{article}  \def\testStr#1{IOIO#1}  \newcommand{\doTest}[1]{% \edef\tmphwp{\testStr{XX}} % \typeout{=\tmphwp=#1=} % \ifx\tmphwp#1{% \typeout{~equal}% }\else{% \typeout{!not equal}% }\fi % \typeout{ ^^J } % newline in terminal stdout }  \begin{document}  \doTest{12}  \doTest{hello}  \doTest{IOIOXX}  \end{document}   Strangely, this seems to always determine strings are unequal - even if I enter specifically the right string - terminal log (from pdflatex) reports:   =IOIOXX=12= !not equal   =IOIOXX=hello= !not equal   =IOIOXX=IOIOXX= !not equal   Hmm ... I would have expected IOIOXX = IOIOXX ?!   Can anyone explain why am I not getting the expected results - and how to get the right comparison? Does this have maybe to do anything with catcodes?  Many thanks in advance for any answers, Cheers!
86659
With this URL:  .  It is broken unless I add a \ to the end in front of a period:   And it works. However in the comments, I can't get this to work: (See the comments)
80727
Recently the URL www.antlr.org was changed from pointing to www.antlr3.org to www.antlr4.org. Needless to say there are links that use www.antlr.org for referring to www.antlr3.org that are now wrong.   While I know that search with www.antlr.org will find if www.antlr.org is in the text, it will not find it in the hyperlinks. How do I search the hyperlinks?
67727
How can I get the value between quotes with an RegEx  for example I want to find all the parameters from the function test  &lt;html&gt;    test("bla");    print("foo");    test("moo"); &lt;/html&gt;   The result must be { "bla", "moo" }
8103
I put up  over on SO with the assumption that the text would be formatted like it is for a question or answer.  I'm not really sure if I was incorrect in my assumption, or if I just formatted my text improperly, as I can't go back and edit what I put in.  Am I missing an obvious feature?  If not, would it be reasonable to request bounty-text edits—perhaps with moderator-approval to prevent abuse?  Edit: I was trying to use markdown to produce an unordered list as part of my bounty.  What you see in the link is a blob of text with dashes separating phrases
6354
It seems like every question on stackoverflow where the asker is using regex to grab some information from HTML will inevitably have an "answer" that says not to use regex to parse HTML.  Why not? I'm aware that there are quote-unquote "real" HTML parsers out there like , and I'm sure they're powerful and useful, but if you're just doing something simple, quick, or dirty, then why bother using something so complicated when a few regex statements will work just fine?  Moreover, is there just something fundamental that I don't understand about regex that makes them a bad choice for parsing in general?
54866
I want to grab the value of a hidden input field in HTML.  &lt;input type="hidden" name="fooId" value="12-3456789-1111111111" /&gt;   I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format  &lt;input type="hidden" name="fooId" value="**[id is here]**" /&gt;   Can someone provide an example in Python to parse the HTML for the value?
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.
52116
I just noticed an odd bug.  Steps to recreate:   Do a search for two tags, using the OR operator.   Observe that it properly returns results that contain either tag. Log out. Do a search for two tags, using the OR operator.   Observe that you only get results for the first tag, the OR and second tag are stripped out of the search.   Is this a bug, or on purpose for some reason?
13695
If I try to put something like this into a question or answer  &lt;!-- &lt;br&gt;s are important here --&gt;   the first &gt; after the "br" is matched to the first &lt; before the "!--", resulting in this being displayed:     s are important here -->   This happens in both previews and actual posts. I'd say it's a bug.  HTML comments shouldn't be treated as regular HTML tags; &lt;!-- should only be matched to --&gt;.
92309
I have a string:   allPunctuation = '~!@#$%^*()_+|}{":?&gt;&lt;`=;/.,][-\'\\';   This string contains APEX's way of escaping characters so I can include the ' and the \ characters.   When I pass this string into the replaceAll() method I get back an error because the escape characters are not carried over and the regex needs the escape characters. Is there a way around this?  ie: when I system.debug allPunctuation I get back: ~!@#$%^*()_+&#124;}{":?>&lt;`=;/.,][-'\ This clearly doesn't have the escape characters anymore.   My second thought was to utilize the matcher method. Documentation found here:    I am not sure why, but it is returning back a false. To me it seems like it shouldn't be affected by the escape quotes. And legalName has all sorts of punctuation in it.   Pattern NonAlphanumeric = Pattern.compile('[^a-zA-Z0-9 ]'); Matcher matcher = NonAlphanumeric.matcher(legalName); //system.debug(matcher) ---&gt; false   Could someone point me in the right direction?
52131
I typed . I believe I tab-completed @rumtscho and fully typed @MarthaF (since she doesn't tab complete). However, other people tell me that a Unicode character was inserted into the message; I can't see it:  Originally, I abandoned this bug report for a lack of reproducibility. But on another machine, I can see the character and managed to reproduce it: press tab, then press backspace. It works anywhere in a message, not just in a @-ping. (Actually, it seems that you just need to un-focus the input box; clicking elsewhere then hitting backspace works, too)  First machine is Firefox 12 (Iceweasel) on Debian GNU/Linux AMD64, testing+unstable. No user scripts. Greasemonkey is installed, but disabled in the extension manager Second machine is Firefox 10 (Iceweasel) on Debian GNU/Linux AMD64, testing+unstable. No user scripts, Greasemonkey not even installed Third machine (just tested) is Firefox 11 (Iceweasel) on Debian GNU/Linux AMD64. Greasemonkey installed and enabled, and there is a global userscript. Does not happen on Chromium 18.0.1025.151, running on machine #3.  So far, that's all the machines I've tested on, and it happens on all of them. It only happens in chat. Easiest way to produce it is to click on the page background, somewhere outside the text box, to un-focus the text box. Then press backspace. Note that not all browsers will display the character, even if its there (check  to see if yours does)
61276
Today, once again, the  came to my attention and I have decided to try to  using XeLaTeX. The result is far from perfect, worse even than Chrome's rendering.  Is there a way I can improve the result? Is XeLaTeX and LuaLaTeX incapable of handling the Ponny?  :  \documentclass[]{article} \usepackage{lmodern} \usepackage{amssymb,amsmath} \usepackage{ifxetex,ifluatex} \usepackage{fontspec} \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} \IfFileExists{upquote.sty}{\usepackage{upquote}}{} \IfFileExists{microtype.sty}{\usepackage{microtype}}{} \usepackage[normalem]{ulem} \setmainfont{Doulos SIL}  \title{html - RegEx match open tags except XHTML self-contained tags - Stack Overflow} \date{} \author{StackOverflow}  \begin{document} \maketitle  Rege̿̔̉x-based HTML parsers are the cancer that is killing StackOverflow \emph{it is too late it is too late we cannot be saved} the trangession of a chi͡ld ensures regex will consume all living tissue (except for HTML which it cannot, as previously prophesied) \emph{dear lord help us how can anyone survive this scourge} using regex to parse HTML has doomed humanity to an eternity of dread torture and security holes \emph{using rege}x as a tool to process HTML establishes a brea\emph{ch between this world} and the dread realm of c͒ͪo͛ͫrrupt entities (like SGML entities, but \emph{more corrupt) a mere glimp}se of the world of reg​\textbf{ex parsers for HTML will ins}​tantly transport a p\emph{rogrammer's consciousness i}nto a w\emph{orl}d of ceaseless screaming, he comes\sout{, the pestilent sl}ithy regex-infection wil​\textbf{l devour your HT}​ML parser, application and existence for all time like Visual Basic only worse \emph{he comes he com}es \emph{do not fi}​ght h\textbf{e com̡e̶s, ̕h̵i}​s un̨ho͞ly radiańcé de\emph{stro҉ying all enli̍̈́̂̈́ghtenment, HTML tags \textbf{lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq}​uid p}ain, the song of re̸gular exp​re\sout{ssion parsing} will exti\emph{​nguish the voices of mor​\textbf{tal man from the sp}​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​}he f\texttt{inal snuf}fing o\emph{f the lie​\textbf{s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T A}}\textbf{LL I​S L}OST th\emph{e pon̷y he come}s he c̶̮om\sout{es he co}\textbf{\sout{me}s t\emph{he} ich​}or permeat\emph{es al}l MY FAC\emph{E MY FACE ᵒh god n\textbf{o NO NOO̼}}\textbf{O​O N}Θ stop t\emph{he an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨ}e̠̅s\texttt{ ͎a̧͈͖r̽̾̈́͒͑e} n\textbf{​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ T}O͇̹̺ͅƝ̴ȳ̳ TH̘\textbf{Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝}S̨̥̫͎̭ͯ̿̔̀ͅ  \end{document}   UPDATE  Using the Doulos SIL font gets me something closer to what Firefox renders but still far from perfect.
62549
I'm having a bit of trouble getting a Python regex to work when matching against text that spans multiple lines. The example text is ('\n' is a newline)  some Varying TEXT\n \n DSJFKDAFJKDAFJDSAKFJADSFLKDLAFKDSAF\n [more of the above, ending with a newline]\n [yep, there is a variable number of lines here]\n \n (repeat the above a few hundred times).   I'd like to capture two things: the 'some_Varying_TEXT' part, and all of the lines of uppercase text that comes two lines below it in one capture (i can strip out the newline characters later).  I've tried with a few approaches:  re.compile(r"^&gt;(\w+)$$([.$]+)^$", re.MULTILINE) # try to capture both parts re.compile(r"(^[^&gt;][\w\s]+)$", re.MULTILINE|re.DOTALL) # just textlines   and a lot of variations hereof with no luck. The last one seems to match the lines of text one by one, which is not what I really want. I can catch the first part, no problem, but I can't seem to catch the 4-5 lines of uppercase text. I'd like match.group(1) to be some&#95;Varying&#95;Text and group(2) to be line1+line2+line3+etc until the empty line is encountered.  If anyone's curious, its supposed to be a sequence of aminoacids that make up a protein.
108395
All I wrote in the interpreter was as follows:  &gt;&gt;&gt; print "Hello, World!"   File "&lt;stdin&gt;", line 1     print "Hello, World!"                         ^ SyntaxError: invalid syntax   How did I even get an error? All I tried to do was run a print command.
2497
I was reviewing in the close votes  when I clicked the "more" link for the specific close reason. I saw the following:    As you can see, the markup is not rendering. There's also a call to .AsHtml() in there which is obviously not markup.  Browser is chrome 31.0.1650.63