Adding a Regex101 URL:   I'm been working on this problem for about 3 and a half hours.  I can't for the life of me figure out what I'm doing wrong. I'm so close to making it work perfectly but I don't know how to check for the first occurrence of {/IF}  My REGEX:  {IF\s*([^}]+)}([\s\S]+)(?:{\/ELSE})([\s\S]+){\/IF}  The file being parsed:  {IF !isLoggedIn}     &lt;a href="/sign-in/"&gt;Sign In&lt;/a&gt; {ELSE}     Welcome back, {&gt;username}!&lt;br /&gt;     {# students}     &lt;li&gt;{#&gt;last_name}, {#&gt;first_name}&lt;/li&gt;     {/#} {/IF}  {IF isLoggedIn}     Beta Testing... {/IF}   For some reason, the regex captures all the way to the second {/IF} as the body of the ELSE
3211
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?
7245
I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir.  The problem is that I can't get the hang of the regexp "mind model" :)  This is the regexp that I came up with to select the files that I would like to exclude   ((ABC|XYZ))+\w*Test.xml  What I would like to do is to select all the files that end with Test.xml but do not start with ABC or XYZ.  Could you please add any resources that could help me in my battle with regexps.  Thanks  The following resource explains a lot of things about regexp
93853
How would you go about creating a random alpha-numeric string that matches a certain regular expression?  This is specifically for creating initial passwords that fulfill regular password requirements.
1707
I have several strings in the rough form:  [some text] [some number] [some more text]   I want to extract the text in [some number] using the Java Regex classes.  I know roughly what regular expression I want to use (though all suggestions are welcome). What I'm really interested in are the Java calls to take the regex string and use it on the source data to produce the value of [some number].  EDIT: I should add that I'm only interested in a single [some number] (basically, the first instance). The source strings are short and I'm not going to be looking for multiple occurrences of [some number].
5132
Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail.
13063
Is it possible to write a regular expression that matches a nested pattern that occurs an unknown number of times? For example, can a regular expression match an opening and closing brace when there are an unknown number of open/close braces nested within the outer braces?  For example:  public MyMethod() {   if (test)   {     // More { }   }    // More { } } // End   Should match:  {   if (test)   {     // More { }   }    // More { } }
2940
How can I test if a RegEx matches a string exactly?  var r = /a/; r.test("a"); // returns true r.test("ba"); // returns true testExact(r, "ba"); // should return false testExact(r, "a"); // should return true
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.
67376
I’m a newbie in Python. I’m learning regexes, but I need help here.  Here comes the HTML source:  &lt;a href="http://www.ptop.se" target="_blank"&gt;http://www.ptop.se&lt;/a&gt;   I’m trying to code a tool that only prints out http://ptop.se. Can you help me please?
70124
Using regular expressions, what is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter):  &lt;html&gt;   &lt;head&gt;   [snip]   &lt;meta name="generator" value="thevalue i'm looking for" /&gt;   [snip]
108707
You can search for anything on Google, right? At least, so I thought. I was trying to see how the special characters get encoded in the url, like how &amp; gets converted to %26. I started searching for *. It did not get encoded, but weirdly google didn't tell me that it was an asterisk symbol. All other search engines (yahoo, bing, duckduckgo) did.   See for yourself : . Basically it treats it as a regular expression. So *+* will also not give any results. Still, shouldn't Google at least say that * is the asterisk symbol.  I don't know where else to ask this question, so I came to SO.
39085
I'm wondering what's the difference between using * and .* in a regex string.  I guess, * stands for "0 to n characters" but I don't see what .* stands for.  For example, what is the difference between: "2013*11*27" and "2013.*11.*27"? If I take a look to   find . -name [pattern]   As pattern I tried : "2013.*11.*25" and it didn't find "2013-11-25" however, with "2013*11*25", it finds it.   Why ?  In unix, 0 or n occurences of wildcards is : *, in regex .* so why doesn't it work ?
23137
I was browsing the html of my favorite site...ahem...and I saw this in the markup:  &lt;link href="/Content/all.min.css?d=20090107" rel="stylesheet" type="text/css" /&gt;   what does "?d=20090107" do? I'm assuming it's a date of some kind, but I'm not sure why it's in the path to the file. Any ideas?
5698
Getting the subdomain from a URL sounds easy at first.  http://www.domain.example   Scan for the first period then return whatever came after the "http://" ...  Then you remember  http://super.duper.domain.example   Oh. So then you think, okay, find the last period, go back a word and get everything before!   Then you remember  http://super.duper.domain.co.uk   And you're back to square one. Anyone have any great ideas besides storing a list of all TLDs?
62677
I am writing a Java utility which helps me to generate loads of data for performance testing.  It would be really cool to be able to specify a regex for Strings so that my generator spits out things which match this.  Is there something out there already baked which I can use to do this?  Or is there a library which gets me most of the way there?  Thanks
12603
I am using the function below to match URLs inside a given text and replace them for HTML links. The regular expression is working great, but currently I am only replacing the first match.  How I can replace all the URL? I guess I should be using the exec command, but I did not really figure how to do it.  function replaceURLWithHTMLLinks(text) {     var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/i;     return text.replace(exp,"&lt;a href='$1'&gt;$1&lt;/a&gt;");  }
123543
I wonder if there is an easy way to check if two strings match by excluding certain characters in the strings. See example below.  I can easily write such a method by writing a regular expression to find the "wild card" characters, and replace them with a common character. Then compare the two strings str1 and str2. I am not looking for such implementations, but like to know whether there are any .Net framework classes that can take care of this. Seems like a common need, but I couldn't find any such method.  For example:  string str1 = "ABC-EFG";     string str2 = "ABC*EFG";   The two strings must be declared equal.  Thanks!