I am attempting to extract all instances of a particular format from a string:
I am wondering if my new Sony [PT# 123456ABC; Sony] has this feature but my friend says the new Toshiba [PT# AD-3232hjk; Toshiba] has this feature.
I would like to extract:
[PT# 123456ABC; Sony]
[PT# AD-3232hjk; Toshiba]
As you can see here, the only items in the consistent positions are:
- [PT#
- ;
- ]
I was attempting to use various types of strpos() but because of the varying lengths and formats of the part numbers and manufacturer names I was unable to reliably pull out those instances from a much larger string. I have been trying various ways to use regular expressions to solve this however my knowledge with them is fairly limited. After I have these expressions extracted and placed into variables I will then need to separate the part numbers and manufacturer names from the expression. This may also be easier to accomplish using regular expressions.
Any help is appreciated. Thanks