Jump to content

Regex help

Go to solution Solved by Blade of Grass,

^[ -~]+$

Will match all printable ASCII characters. 

Edit: thought I'd explain how this works, it starts at the space character and accepts any character (on the ascii table) between that and the tilde (last printable character). This encompasses all letters, numbers, and standard special characters. 

 

Have you considered changing your database character set to allow all character though? That might be a better option. 

Hi, I have a gamer server that can kick players with help of regex and since I'm in EU alot who join has characters the server doesent know (russia for the most).

The game server is unable to save anything to the database becouse all it sees is ????? joined the game and if 2 players have the same length both has the same name for the server.

So i tryed making this (\[A-Z]|[a-z]|[0-9]|[-!$%^&*()_+|~=`{}\\[\]:";'<>?,.\/@#]|[" *"])+ to allow only A-Z a-z 0-9 and all the special characters that everyone has. Tho that one does not work.

Here is the one that is default: ([\x00-\xAA]|[\w_\ \.\+\-])+

If someone could make / show me how to do it I would be happy :)

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/569638-regex-help/
Share on other sites

Link to post
Share on other sites

^[ -~]+$

Will match all printable ASCII characters. 

Edit: thought I'd explain how this works, it starts at the space character and accepts any character (on the ascii table) between that and the tilde (last printable character). This encompasses all letters, numbers, and standard special characters. 

 

Have you considered changing your database character set to allow all character though? That might be a better option. 

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
https://linustechtips.com/topic/569638-regex-help/#findComment-7476192
Share on other sites

Link to post
Share on other sites

8 minutes ago, Blade of Grass said:

^[ -~]+$

Will match all printable ASCII characters. 

Edit: thought I'd explain how this works, it starts at the space character and accepts any character (on the ascii table) between that and the tilde (last printable character). This encompasses all letters, numbers, and standard special characters. 

 

Have you considered changing your database character set to allow all character though? That might be a better option. 

oh snap, what are you some kind of sniper?

Link to comment
https://linustechtips.com/topic/569638-regex-help/#findComment-7476249
Share on other sites

Link to post
Share on other sites

2 hours ago, Blade of Grass said:

^[ -~]+$

Will match all printable ASCII characters. 

Edit: thought I'd explain how this works, it starts at the space character and accepts any character (on the ascii table) between that and the tilde (last printable character). This encompasses all letters, numbers, and standard special characters. 

 

Have you considered changing your database character set to allow all character though? That might be a better option. 

 

2 hours ago, prolemur said:

[\x20-\x7F]+

This should work, basically it matches all characters in an ascii hex range.

 

http://www.asciitable.com/

Okey thank you guys. Well yea it probably would have worked better that way Tho the game server doesent see the symboles and make it to ? which the database just copys so if the game server would be able to view it, I think that could have worked better too.

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/569638-regex-help/#findComment-7477057
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×