Save numbers after text pattern in a vector
Dear all
I have a text file that looks like these:
#——————————————————
# Atomistic spin configuration file for vampire v5+
#——————————————————
# Date: Wed Jul 31 19:19:54 2024
#——————————————————
Time: 1e-15
Field: 0 0 0
Temperature: 0.05
Magnetisation: -0.999883 0.0152572 -0.000478932
#——————————————————
Number of spin files: 1
spins-00000000.data
#——————————————————
I am interested in saving in an array the three numerical values after "Field:". I have tried something like
field_str=regexp(meta_file_read,'(?<=^TField:s+)(S+)s*(S+)s*(S+)’,’match’,’lineanchors’); % T
But the cell seems to be empty.
Any ideas?Dear all
I have a text file that looks like these:
#——————————————————
# Atomistic spin configuration file for vampire v5+
#——————————————————
# Date: Wed Jul 31 19:19:54 2024
#——————————————————
Time: 1e-15
Field: 0 0 0
Temperature: 0.05
Magnetisation: -0.999883 0.0152572 -0.000478932
#——————————————————
Number of spin files: 1
spins-00000000.data
#——————————————————
I am interested in saving in an array the three numerical values after "Field:". I have tried something like
field_str=regexp(meta_file_read,'(?<=^TField:s+)(S+)s*(S+)s*(S+)’,’match’,’lineanchors’); % T
But the cell seems to be empty.
Any ideas? Dear all
I have a text file that looks like these:
#——————————————————
# Atomistic spin configuration file for vampire v5+
#——————————————————
# Date: Wed Jul 31 19:19:54 2024
#——————————————————
Time: 1e-15
Field: 0 0 0
Temperature: 0.05
Magnetisation: -0.999883 0.0152572 -0.000478932
#——————————————————
Number of spin files: 1
spins-00000000.data
#——————————————————
I am interested in saving in an array the three numerical values after "Field:". I have tried something like
field_str=regexp(meta_file_read,'(?<=^TField:s+)(S+)s*(S+)s*(S+)’,’match’,’lineanchors’); % T
But the cell seems to be empty.
Any ideas? text patterns MATLAB Answers — New Questions