简体   繁体   中英

How to write this REGEX - php?

I have this string: list_tablename.json.php?type=arr . I need to grab the tablemane . I could achieve this task through a combination of stripos() and substr() . I would like to know how to accomplish this using regex. In fact how to grab everything between _ and first . ?

Following this post , this pattern (?<=_)(.+)(.json) should work, but it is not. regex

Use a positive lookbehind for _ , and get the portion till next . :

(?<=_)[^.]+

Demo

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