0

I have a Long string from that I want to store the keyword in array or collection, the format of my string is like below:

Title: My Test Page Title.

Desc: My page description.

Keywords: Bessel function, legendre function, Differential Equations, Bessel, Legendre, Homogenous, Assignment & Maths Homework Help.

Bessel & Legendre Function:

Homogenous Equations of the second order of the type + x + ( - )y = 0, v [0, ), x [0, )………………….(1) (1 - ) - 2x + n (n + 1)y = 0, n = 1, 2 ……, x (-1, 1)…………………(2)

In this String I want to store all Keywords in Array/collection split from comma. My problem is that How I can find out the starting and ending point to split the keywords, I can get the Starting point from Keywords: but what should be my ending point to store the keyword in array/collection, there is no any fix format, there is only one fix format which is there will be a Para after ending the Keyword section.

any one can suggest me regular expression for this.

3 Answers 3

2

there will be a Para

Seems like you should first split the string into lines.

And then the line that starts with Keywords: holds your keywords.

You can use the string.Split() method to split into lines as well as for breaking out the keywords.

Sign up to request clarification or add additional context in comments.

Comments

0

It also looks like the Keywords section ends with a fullstop. So you could find the next fullstop ie IndexOf(".") after the "Keywords:" ....

Comments

0

I think this should do:

string afterKeywords = data.Substring(data.IndexOf("Keywords:") + 9);
string beforeNextPara = afterKeywords.Substring(0, afterKeywords.IndexOf(Environment.NewLine + Environment.NewLine));
var dataWeNeed = beforeNextPara.Split(',');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.