Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex 3 Regular Expression Problem
    text
    copied!<p>I've written a url validator for a project I am working on. For my requirements it works great, except when the last part for the url goes longer than 22 characters it breaks. My expression:</p> <pre><code>/((https?):\/\/)([^\s.]+.)+([^\s.]+)(:\d+\/\S+)/i </code></pre> <p>It expects input that looks like "http(s)://hostname:port/location". When I give it the input:</p> <pre><code>https://demo10:443/111112222233333444445 </code></pre> <p>it works, but if I pass the input</p> <pre><code>https://demo10:443/1111122222333334444455 </code></pre> <p>it breaks. You can test it out easily at <a href="http://ryanswanson.com/regexp/#start" rel="nofollow noreferrer">http://ryanswanson.com/regexp/#start</a>. Oddly, I can't reproduce the problem with just the relevant (I would think) part <code>/(:\d+\/\S+)/i</code>. I can have as many characters after the required / and it works great. Any ideas or known bugs?</p> <p>Edit: Here is some code for a sample application that demonstrates the problem:</p> <pre><code>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt; &lt;mx:Script&gt; &lt;![CDATA[ private function click():void { var value:String = input.text; var matches:Array = value.match(/((https?):\/\/)([^\s.]+.)+([^\s.]+)(:\d+\/\S+)/i); if(matches == null || matches.length &lt; 1 || matches[0] != value) { area.text = "No Match"; } else { area.text = "Match!!!"; } } ]]&gt; &lt;/mx:Script&gt; &lt;mx:TextInput x="10" y="10" id="input"/&gt; &lt;mx:Button x="178" y="10" label="Button" click="click()"/&gt; &lt;mx:TextArea x="10" y="40" width="233" height="101" id="area"/&gt; &lt;/mx:Application&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload