Regex for Umlaut

前端 未结 5 1742
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 05:56

I am using JS Animated Contact Form with this line of validation regex:

rx:{\".name\":{rx:/^[a-zA-Z\'][a-zA-Z-\' ]+[a-zA-Z\']?$/,target:\'input\'}, other fie         


        
相关标签:
5条回答
  • 2020-11-30 06:23

    I came up with a combination of different ranges:

    [A-Za-zÀ-ž\u0370-\u03FF\u0400-\u04FF]
    
    • Diacritical Marks: [À-ž]
    • Greek and Coptic: [\u0370-\u03FF]
    • Cyrillic: [\u0400-\u04FF]

    But I see that it misses some letters of @SambitD proposal, refer to: https://rubular.com/r/2g00QJK4rBS8Y4

    0 讨论(0)
  • 2020-11-30 06:24

    The problem with the \uXXXX approach is, that it is not supported by all Regex flavours. For example Visual C++ does not support it. There, you would need to enumerate the actual letters.

    I recommend to use a tool like https://www.regexbuddy.com/ that knows as many flavors as possible.

    0 讨论(0)
  • 2020-11-30 06:32

    I used

    A-Za-z-ÁÀȦÂÄǞǍĂĀÃÅǺǼǢĆĊĈČĎḌḐḒÉÈĖÊËĚĔĒẼE̊ẸǴĠĜǦĞG̃ĢĤḤáàȧâäǟǎăāãåǻǽǣćċĉčďḍḑḓéèėêëěĕēẽe̊ẹǵġĝǧğg̃ģĥḥÍÌİÎÏǏĬĪĨỊĴĶǨĹĻĽĿḼM̂M̄ʼNŃN̂ṄN̈ŇN̄ÑŅṊÓÒȮȰÔÖȪǑŎŌÕȬŐỌǾƠíìiîïǐĭīĩịĵķǩĺļľŀḽm̂m̄ʼnńn̂ṅn̈ňn̄ñņṋóòôȯȱöȫǒŏōõȭőọǿơP̄ŔŘŖŚŜṠŠȘṢŤȚṬṰÚÙÛÜǓŬŪŨŰŮỤẂẀŴẄÝỲŶŸȲỸŹŻŽẒǮp̄ŕřŗśŝṡšşṣťțṭṱúùûüǔŭūũűůụẃẁŵẅýỳŷÿȳỹźżžẓǯßœŒçÇ

    which supports almost all the chars in Europe. Source of truth

    0 讨论(0)
  • 2020-11-30 06:34

    You should use in your regex unicode codes for characters, like \u0080. For German language, I found following table:

    Zeichen     Unicode
    ------------------------------
    Ä, ä        \u00c4, \u00e4
    Ö, ö        \u00d6, \u00f6
    Ü, ü        \u00dc, \u00fc
    ß           \u00df
    

    (source http://javawiki.sowas.com/doku.php?id=java:unicode)

    0 讨论(0)
  • 2020-11-30 06:37

    Try using this:

    /^[\u00C0-\u017Fa-zA-Z'][\u00C0-\u017Fa-zA-Z-' ]+[\u00C0-\u017Fa-zA-Z']?$/
    

    I have added the unicode range \u00C0-\u017F to the start of each of the square bracket groups.

    Given that /^[\u00C0-\u017FA-Za-z]+$/.test("aeiouçéüß") returns true, I expect it should work.

    Credit to https://stackoverflow.com/a/11550799/940252.

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