garrensilverwing
New Member
- Messages
- 148
- Reaction score
- 0
- Points
- 0
to try and speed up the process of adding chess games to my website i would like a piece of code that will search a large string for certain bits of information, so instead of hand typing them into the database every time i could just enter the string and it will do the job for me. here is an example of what i want to do:
this is a PGN format chess game. i need to extract the first and last names (seperately) for both white and black, both their ratings, the ECO, the result and the year. the rest of the information can be discarded. I have no idea how to do this and tutorials online are not very helpful so thanks in advance :biggrin:
Code:
[Event "Wyoming Open"]
[Site "Laramie College"]
[Date "2006.05.06"]
[Round "3"]
[White "James Kulbacki"]
[Black "Chris Peterson"]
[Result "0-1"]
[ECO "A00"]
[WhiteElo "1880"]
[BlackElo "1668"]
[PlyCount "38"]
[EventDate "2006.??.??"]
[TimeControl "35/90:0"]
1. b4 e5 2. Bb2 Bxb4 3. f4 Nc6 4. fxe5 f6 5. exf6 Nxf6 6. Nf3 O-O 7. g3 Ng4
8.c3 Bc5 9. d4 Qe7 10. Qd3 d5 11. dxc5 Bf5 12. Qxd5+ Kh8 13. Nbd2 Rad8
14. Qb3 Qe3 15. c4 Qf2+ 16. Kd1 Rxd2+ 17. Kxd2 Rd8+ 18. Kc1 Ne3
19. Nd2 Qe1+
0-1
this is a PGN format chess game. i need to extract the first and last names (seperately) for both white and black, both their ratings, the ECO, the result and the year. the rest of the information can be discarded. I have no idea how to do this and tutorials online are not very helpful so thanks in advance :biggrin:
Last edited: