non-alphanumeric

Most Pythonic was to strip all non-alphanumeric leading characters from string

我只是一个虾纸丫 提交于 2021-02-05 12:30:45
问题 For example !@#123myname --> myname !@#yourname!@#123 --> yourname!@#123 There are plenty of S.O. examples of "most pythonic ways of removing all alphanumeric characters" but if I want to remove only non-alphabet characters leading up to first alphabet character, what would be the best way to do this? I can do it with a while loop but im looking for a better python solution 回答1: If you want to remove leading non-alpha/numeric values: while not s[0].isalnum(): s = s[1:] If you want to remove

How to remove non alphanumeric characters and space, but keep foreign language in JavaScript

醉酒当歌 提交于 2019-12-21 05:13:06
问题 I want to remove signs like: !@#$%^&*()_+`-=[]\|{};':",./<>?。,‘“”’;【】『』 and many more. But ensuring all the foreign characters are kept, such as Chinese, French, Greece, etc. In Ruby, I'm able to do it with regex /[^\p{Alnum}]/ It doesn't work in JS. Thanks in advance. Answer Thank Jordan Gray. The 8400-letter regex is awesome. It is a short solution as it is only 8.4kb compare to 63kb of XRegExp. For the record, the full answer I use is /[^1-9\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA

How to match with regex all special chars except “-” in PHP?

荒凉一梦 提交于 2019-12-18 13:11:51
问题 How can I match all the “special” chars (like +_*&^%$#@!~ ) except the char - in PHP? I know that \W will match all the “special” chars including the - . Any suggestions in consideration of Unicode letters? 回答1: [^-] is not the special character you want [\W] are all special characters as you know [^\w] are all special characters as well - sounds fair? So therefore [^\w-] is the combination of both: All "special" characters but without - . 回答2: \pL matches any character with the Unicode

Replacing all non-alphanumeric characters with empty strings

时光总嘲笑我的痴心妄想 提交于 2019-12-17 03:48:14
问题 I tried using this but didn't work- return value.replaceAll("/[^A-Za-z0-9 ]/", ""); 回答1: Use [^A-Za-z0-9] . Note: removed the space since that is not typically considered alphanumeric. 回答2: Try return value.replaceAll("[^A-Za-z0-9]", ""); or return value.replaceAll("[\\W]|_", ""); 回答3: You should be aware that [^a-zA-Z] will replace characters not being itself in the character range A-Z/a-z. That means special characters like é , ß etc. or cyrillic characters and such will be removed. If the

Replacing all non-alphanumeric characters with empty strings

心已入冬 提交于 2019-12-17 03:47:00
问题 I tried using this but didn't work- return value.replaceAll("/[^A-Za-z0-9 ]/", ""); 回答1: Use [^A-Za-z0-9] . Note: removed the space since that is not typically considered alphanumeric. 回答2: Try return value.replaceAll("[^A-Za-z0-9]", ""); or return value.replaceAll("[\\W]|_", ""); 回答3: You should be aware that [^a-zA-Z] will replace characters not being itself in the character range A-Z/a-z. That means special characters like é , ß etc. or cyrillic characters and such will be removed. If the

Removing non alphanumeric characters in a batch variable

旧城冷巷雨未停 提交于 2019-11-30 16:06:21
问题 In batch, how would I remove all non alphanumeric (a-z,A-Z,0-9,_) characters from a variable? I'm pretty sure I need to use findstr and a regex. 回答1: The solutionof MC ND works, but it's really slow (Needs ~1second for the small test sample). This is caused by the echo "!_buf!"|findstr ... construct, as for each character the pipe creates two instances of cmd.exe and starts findstr . But this can be solved also with pure batch. Each character is tested if it is in the map variable :test set "

Removing non alphanumeric characters in a batch variable

自作多情 提交于 2019-11-30 15:42:33
In batch, how would I remove all non alphanumeric (a-z,A-Z,0-9,_) characters from a variable? I'm pretty sure I need to use findstr and a regex. The solutionof MC ND works, but it's really slow (Needs ~1second for the small test sample). This is caused by the echo "!_buf!"|findstr ... construct, as for each character the pipe creates two instances of cmd.exe and starts findstr . But this can be solved also with pure batch. Each character is tested if it is in the map variable :test set "_input=Th""i\s&& is not good _maybe_???" set "_output=" set "map=abcdefghijklmnopqrstuvwxyz 1234567890"

SQL Server 2008 query to find rows containing non-alphanumeric characters in a column

拥有回忆 提交于 2019-11-28 21:07:03
I was actually asked this myself a few weeks ago, whereas I know exactly how to do this with a SP or UDF but I was wondering if there was a quick and easy way of doing this without these methods. I'm assuming that there is and I just can't find it. A point I need to make is that although we know what characters are allowed (a-z, A-Z, 0-9) we don't want to specify what is not allowed (#@!$ etc...). Also, we want to pull the rows which have the illegal characters so that it can be listed to the user to fix (as we have no control over the input process we can't do anything at that point). I have

SQL Server 2008 query to find rows containing non-alphanumeric characters in a column

微笑、不失礼 提交于 2019-11-27 13:41:21
问题 I was actually asked this myself a few weeks ago, whereas I know exactly how to do this with a SP or UDF but I was wondering if there was a quick and easy way of doing this without these methods. I'm assuming that there is and I just can't find it. A point I need to make is that although we know what characters are allowed (a-z, A-Z, 0-9) we don't want to specify what is not allowed (#@!$ etc...). Also, we want to pull the rows which have the illegal characters so that it can be listed to the

Replacing all non-alphanumeric characters with empty strings

陌路散爱 提交于 2019-11-26 17:07:26
I tried using this but didn't work- return value.replaceAll("/[^A-Za-z0-9 ]/", ""); Mirek Pluta Use [^A-Za-z0-9] . Note: removed the space since that is not typically considered alphanumeric. Try return value.replaceAll("[^A-Za-z0-9]", ""); or return value.replaceAll("[\\W]|_", ""); You should be aware that [^a-zA-Z] will replace characters not being itself in the character range A-Z/a-z. That means special characters like é , ß etc. or cyrillic characters and such will be removed. If the replacement of these characters is not wanted use pre-defined character classes instead: someString