views:

75

answers:

2

How to write regex for this paricular situation. Here letters in [] is not fixed but letters without [] is fixed.

http://www.abc.com/fixed/[any small letters]/[anyletters]/fixed.html
+4  A: 
http://www.abc.com/fixed/[a-z]+/[a-zA-Z]+/fixed.html

Possibly change to a more forgiving:

http://www.abc.com/fixed/[a-z]+/[^/]+/fixed.html
Wrikken
You forgot a `+` after `[a-zA-Z]` in the first example
Amarghosh
Duly noted, fixed.
Wrikken
.........and +1
Amarghosh
A: 

You can use lookarounds for that. One problem may be that they are not available in every language. For instance Javascript has only positive lookahead.

Oh, you mean something different... try this:

http://www.abc.com/fixed/[a-z]+/[\w\D^_]+/fixed.html
Bundyo
Careful, `\w` also matches digits and `_`.
Tim Pietzcker
Thanks, noted and fixed.
Bundyo