Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strings
#1
Hello

Suppose I have the string s="1. e4 {0s} e5 {Biblio. 0s} 2. d3 {1s (Cf3)} Nc6 {Biblio.
0s} 3. g3 {4s} Nf6 {+0.27/7 2s} *" and the number i=3 and then I want to get the 2 strings "g3" and "Nf6" (they appear after 3. and before * in the string s) . How can i do this please?

Thanks in advance
#2
Use regular expression. If it depends on i, create it with str function format.

Code:
Copy      Help
str s="1. e4 {0s} e5 {Biblio. 0s} 2. d3 {1s (Cf3)} Nc6 {Biblio. 0s} 3. g3 {4s} Nf6 {+0.27/7 2s} *"
int i=3
str rx.format("\b%i\. (\w+) \{.+?\} (\w+)" i)
ARRAY(str) a
if(findrx(s rx 0 0 a)<0) end "not found"
out a[1]
out a[2]


Forum Jump:


Users browsing this thread: 1 Guest(s)