简体   繁体   中英

Regular expression to match a string literal followed by a number

I am using Google Analytics to see which pages are viewed the most of a website, and I need a selection based on a Regular Expression.

What I need to select:

/index.php?page=1203
/index.php?page=12
/index.php?page=15&print=1

Basically I first need to select the literal string of /index.php?page= appended by any number of any length, all integers, so no comma's. After this, anything can be appended so I am thinking an * will do. But please answer one with, and without the * because I need to target both.

Thanks in advance!

You can use this regex with a captured group:

\/index\.php\?page=(\d+)

We are capturing 1+ digits in 1st capture group after matching text /index.php?page=

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM