Click here to Skip to main content
15,882,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to match a pattern of URL.

String to be matched : /uk/en/ or anything like that e.g. /ue/gh/ etc..

Pattern should match /any one character any one character / any one character any one character/

I need to include '/' in the pattern to make sure that its a part of the string..
Thanks!!
Posted
Updated 11-Apr-13 2:04am
v2
Comments
AmitGajjar 11-Apr-13 8:12am    
have you tried somethign ? can you post your code.
cproject123 11-Apr-13 8:29am    
below seem to work ok, please let me know if there is a better solution:

var href = "/bg/bg/";
var mat = href.match(/(^\/..\/..\/$)/)[0];

JavaScript
//If the character can only be alphabets
var pat=/\/[a-z][a-z]\/[a-z][a-z]\//i;
//If character can be anything except newline
var pat=/\/..\/..\//;
 
Share this answer
 
below seem to work ok, please let me know if there is a better solution:

var href = "/bg/bg/";
var mat = href.match(/(^\/..\/..\/$)/)[0];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900