简体   繁体   中英

How to URL folder path regex?

i'm filtering regex result URL path folder

https://stackoverflow.com/questions/16715357/regex-limiting-wildcards-for-url-folders

i use regex expression

\\/[^\\s/\\/]+

so

/stackoverflow.com/questions/16715357/regex-limiting-wildcards-for-url-folders

but, i want to folder path only...

/questions/16715357/regex-limiting-wildcards-for-url-folders

this regex expression add expression?

Try the following regex

Regex description:

  • \\. match a dot
  • \\w+ for matching top level domain
  • \\/ for matching slash after top level domain
  • (.*) capturing group for rest of the URL.

 const str = '/stackoverflow.com/questions/16715357/regex-limiting-wildcards-for-url-folders'; const result = str.match(/\\.\\w+\\/(.*)/); console.log(result[1])

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