Finding and separating unknown text in string

I have a large string that may at times contain something like this:

“Hello, I am text” [[a id=“c-garden-eden” class=“character”]] I need to go to the store.

However the bold characters are unknown when I am parsing the text. They are not always the same. I need to find the bold words and pull them out of the string and store them in their own string to be used in their own method.
How do I find these ever changing characters without disturbing any of the other characters in the string?

You probably want something like regular expressions. You can do them in C# here:

It takes a bit of getting comfortable with the nearly-unreadable syntax involved, but I think they will do what you need them to do for the problem above.

If that is the format of the string and you always get it in that format, you could split it on the " parts and just take the pieces you need. But that only works if you get the exact format back each time.

The problem with this is those "e; tags show up in areas where I don’t want to find the text between them so using the quote&; will yield in pulling strings I don’t want.

Well, like I said, you split the string and grab only what you want from the array it returns. Otherwise, as @Kurt-Dekker suggested, regular expressions is really about your only other choice that I can think of. That string is really oddly formatted. Otherwise, if that string is a certain type, you might be able to use the proper parsing. (but I’m not sure that string matches anything)

Where are you getting the string from?

Also keep in mind that regexes aren’t magic. They only encode the best intentions of the person who designed them and obviously work best on REGULAR-ly formatted data.

If you have truly ad-hoc data that will take forward-looking analysis to successfully parse, then you are going to have to supply a mechanism to update your regex after the game is delivered (either updating the app or sending it fresh data) in order to cope with “all future un-thought-of ways of making that string.”

I’m looking into the regular expressions but am really new to working with strings so I’m not quite sure I understand it yet.
The string comes from an XML file provided to me by someone else. I have to adhere to this format.

So I would need to put in every variation of the contained string in order for it to work? The text around the bold words will always be the same, it is only the bold words and those characters outside of the brackets that will change.

Well, if the text around is always the same, the split method may be better. However, from looking at it, if you simply need id and class, you should be able to use a regex to get those.