javascript - Write a regexp parsing URL -


i trying write regex following

if have url

example.com?mask=33&filter=23423&mode=12 

it match substring filter=23423

i need consider url can be

example.com?filter=23423 

thanks in advance.

you may not consider [\?&] in regexp , put /filter=[0-9]*/ if sure there not params other_filter=987 in url. if may have such use substr on resulted regexp

url.match(/[\?&]filter=[0-9]*/)[0].substr(1) 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -