how to identify strings on a text file

1 次查看(过去 30 天)
Hello,
I want to open a text file, and identify a string. The text file can have multiple lines. For instance I want to find the term "AX" wherever it is on the text file and then do something according to the next chars (AX=1 does something different from AX=2). Any help appreciated,
regards, Hugo

采纳的回答

Rainer
Rainer 2013-3-13
  1 个评论
Hugo
Hugo 2013-3-13
Thanks for replying. Do you know can I move through columns in a text file? I know I shall use a for cycle, but I don't know how to do it.
regards, Hugo

请先登录,再进行评论。

更多回答(1 个)

Hugo
Hugo 2013-3-14
Hi,
The file is a programming file, with several lines. Every line has at least a char. I want to identify the string AX (for instance), then according to its value I want to assign a value to a variable, let´s say "var1" so, as an example, -if It finds AX equal to 2, it assigns a value to the variable var1, lets say 1, and if it finds AX equal to 5, it assigns the value 2
How can I do that? The line where AX appears can vary.
Thanks for replying regards, Hugo
  1 个评论
Cedric
Cedric 2013-3-14
编辑:Cedric 2013-3-14
But do you have a content that looks like this:
ID=1, AX=28.3, BX=17, STRID="Oregon"
ID=2, AX=24.7, BX=9, STRID="Michigan"
which has a regular structure, or is it more like that:
var n = doc.createElement("input"); n.type = "hidden"; n.name = "c[AX=28.1]"; newElem.value = "contest"; doc.forms['search', AX=25.7].appendChild(n2); select = 8;
which has no regular structure?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by