开发者

Extracting the required keywords from text

I have texts like this and the formats are given below.

Salary is 3.6L PA
Salary is 3.5 LPA
Salary is 30,000KPM
Salary is 30,000 KPM
Experience: 3-5years
Experience: 3+ years

Now I need to find Salary like 3.5 or 30,000 and Experience or Minimum experience 3years. If there is space then the experience is working fine but Salary is not working. But if experience "3" and "+" have no place with in it, cant get the result.

Can any one please suggest me the logic to how to get those for both salary and experience.

The only Co开发者_JAVA技巧ndition is Salary and the amount will always be in same line and Experience and value will also be in same line.

Thanks in advance.


Regular expressions are your friend.

Try the following:

foreach (Match match in Regex.Matches(content, "^(.*?)\\s*(?::| is )\\s*([0-9,.+-]+)(.*)$", RegexOptions.Multiline))
{
    Console.WriteLine("Item1: {0} Item2: {1} Item3: {2}", match.Groups[1].Value, match.Groups[2].Value, match.Groups[3].Value);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜