Reputation: 450
I have a string like this:
1. Zentrallager # TF Schrankwandp (u) -EG- 2. ASH 25 # TF silentglider (u) WS 3. Gutinedu # TF ottomatic 4. Deep Space Three # TF Kleissi1978 F & P 5. crafted by trapper12 # TF trapper12 VR 6. -8- # TF Mrs-Shooter (u) -=SC=- 7. 8. Standard Libelle # TF silentglider (u) WS 9. crafted by phiLLLdd # TF phiLLLdd -=SC=- 10. V8 Vote111 (u) 3R 11. Nimbus # TF silentglider (u) WS 12. Speed Astir # TF silentglider (u) WS 13. I Want My Tears Back # TF KlappstuhI (u) ReX 14. RK-Weporinag # TF ImperatorMar (gu) -=SC=- 15. RK-Hohoieugo # TF -sledge- (gu) > TdE < 16. Oununu # TF Xantros
and I need the values between the "1." and "2." and "2." and "3." .......
My try looks like this:
for($i=1;$i<16;$i++){ // I know there are ever 16 counts
$j = $i+1;
$regex = "/$i\. (.*) $j\./";
preg_match_all($regex, strval($string),$matches);}
My result is empty every time. Matches count is 0. Why?
The variable is definitely a string and the regular expression is functional in some online testers but not in my script.
Upvotes: 0
Views: 96
Reputation: 533
How about:
$arr=preg_split ("/[\d|\d\d]\./", $yourstring)
Now $arr[n] will contain part n+1 of the string
Upvotes: 2