Question: I am writing a web crawler using Scrapy and as a result I get a set of URLs like: [Dummy URLs]
\*<http://matrix.com/en/Zion>

<http://matrix.com/en/Machine_World>

<http://matrix.com/en/Matrix:Banner_guidelines>

<http://matrix.com/en/File:Link_Banner.jpg>

<http://matrix.com/wiki/en/index.php>\*

In the rules in scrapy, I want to add a regex that allows urls ONLY of the kind "<http://matrix.com/en/Machine_World>" or "<http://matrix.com/en/Zion>"
i.e urls that contain anything outside of the set "<http://matrix.com/en/><[a-zA-Z,\_]>" must not be allowed. 

Constraints : 

* The string after "/en/" could be of any length. So I cannot ask it to look only for the first 10 or 20 characters. e.g when I use the regex : [a-zA-Z,*]{1,20} OR [a-zA-Z,*]{1,} it still matches the URLs like <http://matrix.com/en/Matrix:Banner_guidelines> coz it finds "<http://matrix.com/en/Matrix>" part of the url a successful match. I want it look at the string starting after "/en/" till the end of URL and then apply this rule. 
Unfortunately I cannot extract that string n write a sub-routine of any kind. It has to be done using a regex only!

Answer: 
> 
> i.e urls that contain anything outside of the set "<http://matrix.com/en/><[a-zA-Z,\_]>" must not be allowed.
> 
> 
> 

Have you tried using this character class in your regex? Looks like you aren't including underscores.

Try 

```
[a-zA-Z,_]+

```

The plus sign means "one or more" - which is the same as {1,} just a nice shorthand :)

If you want to exclude items with .php or .jpg, feel free to add a $ sign to the end, as so:

```
[a-zA-Z,_]+$

```

The $ means "end of line" meaning that your matching sequence must run to the end of the line. As fullstops are not included in the character class, those options will be excluded

Let me know if that works,
Elliott
Reproducible evidence that the suggested regex works:

```
grep("matrix.com\\/en\\/[a-zA-Z,_]+$", x, perl=TRUE, value=TRUE)
#[1] "http://matrix.com/en/Zion"         
#[2] "http://matrix.com/en/Machine_World"

```

**Data**

```
x <- c("http://matrix.com/en/Zion", "http://matrix.com/en/Machine_World", 
       "http://matrix.com/en/Matrix:Banner_guidelines",
       "http://matrix.com/en/File:Link_Banner.jpg",
       "http://matrix.com/wiki/en/index.php")

```