[英]Extracting custom tags from text file
I am creating my own file tagging system for an application and have not found any relevant information on the subject. 我正在为应用程序创建自己的文件标记系统,但未找到与此主题相关的任何信息。
My application appends tags to the end of a specified file, like so: 我的应用程序将标签附加到指定文件的末尾,如下所示:
If the user wants to mark a particular file as private (for example), the following text will be appended to the end of the specified file: 例如,如果用户要将特定文件标记为私有,则将以下文本附加到指定文件的末尾:
$/private* $ /私人*
Now, I'm trying to figure out how I would extract those tags, and separate them when the file is loaded into my application: 现在,我试图弄清楚如何提取这些标签,并在文件加载到我的应用程序中时将它们分开:
For example, if the file has 3 tags, named "Private", "bad", "jokes". 例如,如果文件具有3个标记,分别命名为“私人”,“不良”,“笑话”。 Then I want my application to get those tags and display them like so:
然后,我希望我的应用程序获取这些标签并像这样显示它们:
This file is marked as private, and contains bad jokes. 该文件被标记为私有,并且包含恶作剧。
OR - Another way to show them would be: 或-显示它们的另一种方法是:
This file has the following tags: Private Bad Jokes 该文件具有以下标签:私人恶作剧
you can put markers for marking beginning of tags and separate tags from each other: 您可以放置用于标记标记开头的标记,以及将标记彼此分开的标记:
main text of the file.......................
+++$$$+++private|bad|jokes+++$$$+++
then you can load the text of file and extract the tags based on the sentinels setup by you. 然后您可以加载文件的文本并根据您设置的标记来提取标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.