Friday, 15 February 2013

Regex without * operator -



Regex without * operator -

here input text:

string input = "current year is: 2014";

i want find first alphabetic word(without numbers) using posix character classes. next regex works , finds 'current'

string pattern = "\\p{alpha}*"; //current

but not allowed utilize * operator. therefore, question, how can same result without using * ?

use + :

string pattern = "\\p{alpha}+";

it's pretty much same, "zero" occurencies aren't allowed.

regex

No comments:

Post a Comment