strange regex ungreedy behavior -


I'm trying to understand why the following Regex: \ / .++ Ext / is not working as a work in the following sentence: http: //slash1/slash2/slash3.ext/slash4 .

In fact, I'm only interested in part matching. For the first time with the URL '.ext' extension, though I add the unorganized character to the backslash, it reduces the scope to the backslash, but it is not so. Really matches: // slash1 / slash2 / slash3.ext/

Here is the link to check:

Edit: Just in case of living in another country, in the end, I ended up using the following regdes: [ ^ \ /]

Your regex first Slash encounters it and ext tells it your match.

You now have two possibilities, you can either go for a look-around, which are more complex, or you do not allow slash to match between two slashes:

  \ / [^ \ /] +? \. Ext \ /  

(Note: I ran away from the dot which is part of the extension, otherwise it would match slash3aext

< / P>

I'm just guessing, but I think that from the "thought" to right to the left ( when I encounter.) Until I get a slash on the left, I ), when you think from left to right, like a rijks check your string.


Comments