How do I match latin unicode characters in ColdFusion or Java regex?

后端 未结 1 1759
一向
一向 2020-12-21 03:58

I\'m looking for a ColdFusion or Java regex (to use in a replace function) that will only match numbers [0-9], letters [a-z], but include none ASCII Portuguese

相关标签:
1条回答
  • 2020-12-21 04:20

    Try alphanumeric character class: \w, it should match letters, digits, and underscores.

    Also you can use special named class \p{L} (I don't know, does Java RegEx parser support it). So in C# your task can be done using following code:

    var input = "informação 123 ?:#$%";
    var result = Regex.Replace(input, @"[^\p{L}\s0-9]", string.Empty);
    

    Regex [^\p{L}\s0-9] means: any character not in this class (all letters, white space, digits). Thereby it matches in your example ?:#$% and we can replace these characters with empty string.

    0 讨论(0)
提交回复
热议问题