Home > other >  UTF8 Regex to check if string is all non-alphanumeric OR starts with period
UTF8 Regex to check if string is all non-alphanumeric OR starts with period

Time:03-06

Here are some examples of what the results should end up with

#!^# true (only symbols)

.234 true (begins with a .)

^ true (only symbol)

'l test false

"This is quoted" false

test false

#93 false

834 false

JS# false

Foo Bar false

今日は false

Any help would be greatly appreciated

CodePudding user response:

Updated Answer:

So as @kylex informed me of the existence of \p{L}\p{N}, you can use ^(?:\.. |[^\p{L}\p{N}] )$

Test Here

Original Answer:

For english language, you can use ^(?:\.. |[^a-zA-Z0-9] )$

Test Here

To get what you are truly asking for here, you'd have to know what classifies as an alphanumeric character of every single language you deem necessary. You would add these characters to the pattern as so:

^(?:\.. |[^a-zA-Z0-9<insert alphanumeric chars here>] )$

CodePudding user response:

Use the ^(\.. |[^A-Za-z0-9] )$ pattern to match all Latin alphabet test cases.

  • Related