0

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

Community
  • 1
  • 1
IgorAlves
  • 5,086
  • 10
  • 52
  • 83

1 Answers1

1

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

(?<=_)[^.]+

Demo

heemayl
  • 39,294
  • 7
  • 70
  • 76