简体   繁体   English

如何检索子字符串?

[英]How to retrieve a substring?

I have a string in a variable tLine. 我在变量tLine中有一个字符串。

Example

 156 \zEntry lx ge ....

I would like to retrieve the substring starting with \\zEntry. 我想检索以\\ zEntry开头的子字符串。

Chapter 6.2.7 of the User's Guide is about Retrieving the Position of a Matching Chunk 用户指南的第6.2.7章是有关检索匹配块的位置的

So I do 所以我做

 get offset("\zEntry",tLine)
 put it into tCharStartPosition
 put the number of chars of tLine into tLength
 put char tCharStartPosition to tLength of tLine into tResultingSubstring

I assume there are simpler ways to do this? 我认为有更简单的方法可以做到这一点? How do they look like? 它们看起来如何?

是:

put char offset("\zEntry",tLine) to -1 of tLine into tSubstring

Along the same lines that David posted... 遵循大卫发布的原则...

get char offset("\\zEntry",tLine) to the number of chars of tLine of tLine 将char offset(“ \\ zEntry”,tLine)转换为tLine的tLine的字符数

The two close end references to "tLine" throw new users until they get used to it, though it makes sense. 尽管这很有意义,但是对“ tLine”的两个结尾引用会引发新用户,直到他们习惯为止。 For example: 例如:

get char 3 to 20 of tLine --straightforward, with arbitrary values 3 and 20 获得tLine的char 3至20-直截了当,具有任意值3和20

and this is constructed as: 构造为:

get char ("3"--start char derived from the offset) to ("20" --end char derived from the length of the string itself) of tLine 获得tLine的char(“ 3”-从偏移量开始的char)到(“ 20”-end由字符串本身的长度得出的char)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM