我已经设计了一个多语种网站,并在数据库中的一些价值观有,它会代替它的语言值标记,删除标签括号(如遇{})或完全删除。
I've designed a multilingual web site and some values in database have a tag which will be replaced with it's language value, remove tags brackets ( in case {} ) or removed completely.
有两种情况:
删除括号:
value {mm} >> value mm
删除完全:
value {mm} >> value
还有{}标签可以是任意长度,可包含 -
Also {tag} could be any length and can contain -
任何人可以帮助我与正则表达式?
Can anybody help me with regex?
下面是一些code,你可能会发现有用。对于许多的许多的更多选项,请参见定期-EX pressions.info 。
Here is some code you might find useful. For many many more options, see Regular-expressions.info.
所有code 使用System.Text.RegularEx pressions;
删除所有出现的 {毫米}
(和仅的毫米
):
Remove all occurrences of {mm}
(and only mm
):
Regex.Replace(myString, "{mm}", String.Empty, RegexOptions.None);
替换 {毫米}
(和仅的毫米
)使用毫米:
Replace all occurrences of {mm}
(and only mm
) with mm
:
Regex.Replace(myString, "{mm}", "mm", RegexOptions.None);
删除的所有实例{任何字符}
:
Regex.Replace(myString, @"{[\-a-z]*}", String.Empty, RegexOptions.IgnoreCase);
替换的所有实例{任何字符}
与的任何字符
:
Regex.Replace(myString, @"{(?<tag>[\-a-z]*)}", "${tag}", RegexOptions.IgnoreCase);
上一篇:PhoneGap Windows8 的自定义插件将调用 c# 代码自定义、插件、代码、PhoneGap
下一篇:解析 Android L 的数据失败.不支持的 major.minor 版本 51.0不支持、版本、数据、Android