Is there a function to extract matching terms (terms that match a regex pattern) from a string and into an array?
For example, if I had a string that said "aba.....bbb......ccc.....bba.....ada" and I had the regex pattern "/a[a-z]a/", I would want to get an array with two entries, "aba" and "ada". I searched for such a function in the API but couldn't find one. Is there any sort of function that will provide this sort of functionality? It would make my life a whole lot easier, although I can do what needs to be done with a lot of replace()s and explode()s.
Function to extract matching terms from a string
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Function to extract matching terms from a string
Code: Select all
preg_match_all()Re: Function to extract matching terms from a string
Ahhh, yes. Silly me, I didn't think before to check the parameter list for extra return values.
Thanks
Thanks