2013年9月17日星期二

The string how to achieve regular extraction and replacement

String:

str = "abc age: {at # A.age} abc sex {at # A.sex} abc age: {at # B.age } abc sex {at # B.sex} ";

How to extract characters in regular : A.age, A.sex, B.age, B.sex

and will:
{at # A.age} replaced by 100, {at # A.sex} replacement for men
{at # B.age} replaced by 50, {at # B.sex} replacement for women


premise # A, # B may be other characters.
------ Solution -------------------------------------- ------
look java interception function split with regular
------ For reference only ------------------ ---------------------
function split with regular right

没有评论:

发表评论