jay_t55
jay_t55

Reputation: 11662

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". 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


Does anybody know how I would go about doing this? I'm thinking maybe using strings as I don't like Regex. It gives me headaches.

Upvotes: 0

Views: 553

Answers (1)

TheVillageIdiot
TheVillageIdiot

Reputation: 40512

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.

Upvotes: 2

Related Questions