Need to get year as a string values

Posted by Gudevg under C# on 4/10/2012 | Points: 10 | Views : 1779 | Status : [Member] | Replies : 11
I have a content like below from that I want to select only the year information as string values.

Given this input string:

For example, one of the major problems is that the observer dynamics are assumed to be faster than that of the state feedback controller, which will cause numerical difficulty (Astrom and Wittenmark, 1997). What's more, when the process constraints are activated, the significant deterioration of closed-loop control performance will be clearly witnessed as kind of nonlinearity is dominating the control system (Tenny, Rawlings, and Wright, 2004). Therefore, it is necessary to develop methods capable of tackling the above problems.

I would like to extract 1997 and 2004.

Notes:

Year information occurs only in four digits
Most probably it ends with full stop (period) or close bracket
It may occur at any place within the paragraph

Deepakkumar G.


Responses

Posted by: Sakthi.Singaravel on: 4/10/2012 [Member] Silver | Points: 25

Up
0
Down
Here u can use Regex.Matches(input,"\s\d{4}[.)]", Regex_options)....



Regards,
Singaravel M

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gudevg on: 4/10/2012 [Member] Starter | Points: 25

Up
0
Down
Okay Singaravel M.


Thanks,

Deepakkumar G.

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/10/2012 [Member] Silver | Points: 25

Up
0
Down
Before year space character must come means use this...

\s\d{4}[.)]

may be means, use this..

\d{4}[.)]

Regards,
Singaravel M

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gudevg on: 4/10/2012 [Member] Starter | Points: 25

Up
0
Down
Need to use \s\d{4}[.)] only



Deepakkumar G.

Gudevg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mani5155 on: 4/10/2012 [Member] Starter | Points: 25

Up
0
Down
DateTime.Now().Year.ToString();

refer it http://msdn.microsoft.com/en-us/library/system.datetime.year.aspx

Top Forums Authors
Wed, 18-Oct-2017 Authors
All Time Authors
Jayakumars
6050
Karthikanbarasan
3455
Oswaldlily
3300

Latest members | More ...


(Statistics delayed by 5 minutes)
Advertisements