【发布时间】:2014-10-23 15:51:13
【问题描述】:
我正在尝试使用正则表达式生成 C# 属性。我有 100 多个,而且任务可能会重复,所以值得付出努力。
要转换的字符串:
Do you own your property?
How is it owned?
Relationship to other registered owner
Estimated value of Estate (joint)
Address Line 1
Are any of the children under 18 years old?
Are you interested in safeguarding your assets for your children/beneficiaries?
预期结果:
public string DoYouOwnYourProperty { get; set;}
public string HowIsItOwned { get; set;}
public string RelationshipToOtherRegisteredOwner { get; set;}
public string EstimatedValueOfEstateJoint { get; set;}
public string AddressLine1 { get; set;}
public string AreAnyOfTheChildrenUnder18YearsOld { get; set;}
public string AreYouInterestedInSafeguardingYourAssetsForYourChildrenBeneficiaries { get; set;}
我四处打听,发现they would remove special chars 或would UpperCase it in code 的正则表达式问题的味道,但不能同时使用正则表达式。
([a-zA-z])( [a-zA-z])([a-zA-z])
替换:
\1\U2\3
但是第 2 组没有大写,我不确定如何为所有内容而不是每个组附加 public string 和 { get; set;}。
【问题讨论】:
-
大写不是“标准”正则表达式操作,它取决于工具。你在用什么?
-
@LucasTrzesniewski 开发正则表达式我使用 101regex,替换我打算使用 notepad++。
标签: regex