Discriminate specific text via script

Hi everyone.

I have a text file and I’m already able to read it, but I need to discriminate the part’s of the text I want to put them on unity text’s.

Anyone knows if it’s any kind of way (on c#) to find the specific parts of the text? Maybe labeling them with #, @ or symbols like this ones, that woud be great since my file is a markdown file (.md) and it’s already labeled, but I don’t know.

Have a nice day to everyone, and thank’s for the help ^^

You need to figure out where to start reading, and where to end reading. There’s a bunch of methods to help you with that.

string.IndexOf can help you find indexes of eg. # or @ or whatever. Eg. "hello #sailor".IndexOf('#') is 6. You can pass it a second argument to specify where to start looking.

string.substring gives you a substring with a start and end index. So eg "hello, sailor".Substring(7, 6) is “sailor”.

Here’s an example to get you started:

private void Start() {
    var input = "this is some text#isn't it great#I love text!";

    var indexOfFirst = input.IndexOf('#');
    var justAfterFirst = indexOfFirst + 1;
    var indexOfSecond = input.IndexOf('#', justAfterFirst);

    var substring = input.Substring(indexOfFirst, indexOfSecond - justAfterFirst);
    print(justAfterFirst);
    print(indexOfSecond);
    print(substring);
}
2 Likes

This is just what I need!!

I think that I have what I need to continue, thank you ^^