Questions tagged [non-alphanumeric]

65 questions
452
votes
16 answers

Stripping everything but alphanumeric chars from a string in Python

What is the best way to strip all non alphanumeric characters from a string, using Python? The solutions presented in the PHP variant of this question will probably work with some minor adjustments, but don't seem very 'pythonic' to me. For the…
Mark van Lent
  • 12,641
  • 4
  • 30
  • 52
233
votes
14 answers

Replacing all non-alphanumeric characters with empty strings

I tried using this but didn't work- return value.replaceAll("/[^A-Za-z0-9 ]/", "");
Alex Gomes
  • 2,385
  • 2
  • 15
  • 6
43
votes
4 answers

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

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.…
Jay
  • 4,240
  • 3
  • 26
  • 39
14
votes
3 answers

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

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?
CaTz
  • 305
  • 3
  • 5
  • 20
11
votes
1 answer

RegEx (in JavaScript find/replace) - match non-alphanumeric characters but ignore - and +

We have been using the following js/regex to find and replace all non-alphanumeric characters apart from - and + outputString = outputString.replace(/[^\w|^\+|^-]*/g, ""); However it doesn't work entirely - it doesn't replace the ^ and | characters.…
Phil Baines
  • 205
  • 4
  • 10
10
votes
3 answers

Place an escape sign before every non-alphanumeric characters

I am trying to place an escape sign before every non-alphanumeric character: > my $b = "!@#%^||" ~ "/welcome xyz:!@#\$%^&*()|:;.,?/-." !@#%^||/welcome xyz:!@#$%^&*()|:;.,?/-. > my $c = $b.subst(/<:!L + :!N - [./-]>/, "\\" ~ $/, :g) \ \ \ \ \ \ \…
lisprogtor
  • 5,677
  • 11
  • 17
6
votes
2 answers

remove all non-alphanumeric characters from lua string

I checking string for a non-alphanumeric char. if(str:match("%W")) then --make str alpha-numeric end How to remove all non-alphanumeric chars from string using lua?
polski
  • 61
  • 1
  • 1
  • 2
5
votes
1 answer

How can I search for rows that contain a non-alphanumeric or space character?

I want to search a table for all rows that contain a non-alphanumeric and non-space character in a specific field. What I have so far: SELECT * FROM myTable WHERE myField LIKE '%[^a-zA-Z0-9]%' As far as I can tell, this returns all non-alphanumeric…
froadie
  • 79,995
  • 75
  • 166
  • 235
5
votes
1 answer

How to count non-alphanumeric characters on pandas dataframe

Here's my data No Body 1 DaTa, Analytics 2 2 StackOver. 67% Here's my expected output No Body Non Alphanumeric 1 DaTa, Analytics 2 1 2 StackOver. 67% 2 I am only count non-alphanumeric like ! @ # & (…
Nabih Bawazir
  • 6,381
  • 7
  • 37
  • 70
4
votes
2 answers

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

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…
Ivan Wang
  • 8,306
  • 14
  • 44
  • 56
4
votes
3 answers

Removing non alphanumeric characters in a batch variable

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.
user1248084
4
votes
3 answers

Lua: How to check if a string contains only numbers and letters?

Simple question may have a simple answer, but my current solution seems horrible. local list = {'?', '!', '@', ... etc) for i=1, #list do if string.match(string, strf("%%%s+", list[i])) then -- string contains characters that are not…
unwise guy
  • 1,048
  • 8
  • 18
  • 27
4
votes
6 answers

Regular Expression for a password with at least 8 characters and at least 1 non-alphanumeric character(s)

I am trying to make a check in PHP if a user changes their password their new password must be 8 or more characters and with at least 1 non-alphanumeric password. How should I check this and what would the regex be? Checking the length is the easy…
Johnathan Au
  • 5,244
  • 18
  • 70
  • 128
3
votes
0 answers

standard non-alphanumeric sort order

Is there a standardised sort order for NON-alpha-numeric characters that is used across most systems / programs? For instance, when I create a bunch of items with symbols as the first character and then sort by Name in Windows 10, I get this…
AutoBaker
  • 919
  • 2
  • 15
  • 31
3
votes
2 answers

How do I match non-letters and non-numbers after a bunch of numbers?

I'm using Ruby 2.4. I want to match a bunch of non-letter and numbers, followed by one or more numbers, followed by an arbitrary amount of non-letters and numbers. However, this string 2.4.0 :001 > token = "17 Milton,GA" => "17…
Dave
  • 15,639
  • 133
  • 442
  • 830
1
2 3 4 5