Regular Expressions Lowercase

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
PHP:
preg_match_all('/\[(\w+) "([^"]+)"\]/', $game, $matches, PREG_SET_ORDER);
hey guys, I have this regular expression that is supposed to grab information from a large string. unfortunately it only works if i strtolwr the entire string first. i want it to grab information as is, without having to convert everything to lower case. this is causing me a headache because i am not very good with regular expressions. if you need more information let me know.
 

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
Add the i tag, this makes it case insensitive, although it does seem odd that it isn't accepting it currently as you don't appear to have anything case sensitive in there. Also, what are you trying to match, as you seem to have an odd layout for the ranges.
PHP:
preg_match_all('/\[(\w+) "([^"]+)"\]/i', $game, $matches, PREG_SET_ORDER);
 
Last edited:

garrensilverwing

New Member
Messages
148
Reaction score
0
Points
0
I'll try adding the /i and see if that helps

[Event "September 2010 DCC Tuesdays"]
[Site "?"]
[Date "2010.09.07"]
[Round "1"]
[White "Patin, Andre"]
[Black "Willis, Mark"]
[Result "1/2-1/2"]
[ECO "B03"]
[WhiteElo "1447"]
[BlackElo "2040"]
[PlyCount "60"]
[SourceDate "2010.01.06"]
[WhiteTeam "12777488"]
[BlackTeam "12199280"]

1. e4 Nf6 2. e5 Nd5 3. c4 Nb6 4. d4 d6 5. f4 dxe5 6. fxe5 c5 7. d5 e6 8. Nc3
exd5 9. cxd5 c4 10. Nf3 Bb4 11. Bxc4 O-O 12. Bb3 Na6 13. Bg5 f6 14. d6+ Kh8 15.
Bf4 fxe5 16. Bxe5 Bg4 17. Bxg7+ Kxg7 18. Qd4+ Qf6 19. Qxg4+ Kh8 20. O-O Bxd6
21. Ne4 Qf4 22. Qxf4 Bxf4 23. Neg5 Nc5 24. Bc2 h6 25. Nh3 Be3+ 26. Kh1 Nc4 27.
Nh4 Rxf1+ 28. Rxf1 Nxb2 29. Rf7 Kg8 30. Rh7 b5 {Game drawn} 1/2-1/2

that is an example of what i am trying to match. i want to grab everything that is inside the brackets, maybe that will clear it up a little?
 
Top