Regex only capturing last instance of capture group in match

Regardless of the problem, ActionScript and JavaScript should always yield the same results, as they both implement ECMAScript (or a superset thereof, but for regular expressions they should not disagree). But yes, this will be happening in any language (or rather any regex flavor). The reason is that you are repeating the capturing group. Let’s … Read more

Is there a regex flavor that allows me to count the number of repetitions matched by the * and + operators?

You’re fortunate because in fact .NET regex does this (which I think is quite unique). Essentially in every Match, each Group stores every Captures that was made. So you can count how many times a repeatable pattern matched an input by: Making it a capturing group Counting how many captures were made by that group … Read more

What is a non-capturing group in regular expressions?

Let me try to explain this with an example. Consider the following text: http://stackoverflow.com/ https://stackoverflow.com/questions/tagged/regex Now, if I apply the regex below over it… (https?|ftp)://([^/\r\n]+)(/[^\r\n]*)? … I would get the following result: Match “http://stackoverflow.com/” Group 1: “http” Group 2: “stackoverflow.com” Group 3: “https://stackoverflow.com/” Match “https://stackoverflow.com/questions/tagged/regex” Group 1: “https” Group 2: “stackoverflow.com” Group 3: “https://stackoverflow.com/questions/tagged/regex” But … Read more