mySql - find non-Ascii character in html [duplicate] - mysql

This question already has answers here:
How can I find non-ASCII characters in MySQL?
(10 answers)
Closed 9 years ago.
I'm trying to find all non-asci characters I have in my DB in a specific table and column. In that column are stored Html description, and in some of them I've exotic or non-existing characters (for example: Hà¶ganà¤s ).
I'm triyng to match them with this query:
SELECT * FROM project_version WHERE description REGEXP '[^()\x00-\xFF\,\.-\<\>="\' /:;&=]'
But I think I'm missing something, cause it returns all of my records. Does anyone any advice?
Thanks in advance

Try moving hyphen to start or end otherwise it needs to be escaped also ^ will be treated as literal ^ in character class:
SELECT * FROM project_version WHERE description REGEXP '[()\x00-\x7F,.<>="\' /:;&=-]'

Related

Mysql regexp to get right table names from database schema [duplicate]

This question already has an answer here:
How to match a fixed string ending with a number using regex [duplicate]
(1 answer)
Closed 2 years ago.
I'm trying to select, from mysql, some specific tables that matches a pattern.
The specific pattern I'm looking for is like 'my_table_number'. For example, my_table_436814 or my_table_35413. The thing is that there are other tables that looks like my_table_old_14353 or my_table_351434_times. I just want to filter out the ones that are my_table_number.
I have tried different patterns, but failed to get what I really need.
The most closest approach was with this:
select table_name from
information_schema.columns ca
where ca.table_name REGEXP '[0-9]$'
How can I achieve what I'm looking for?
Use
REGEXP '^my_table_[0-9]+$'
See proof
NODE
EXPLANATION
^
the beginning of the string
my_table_
'my_table_'
[0-9]+
any character of: '0' to '9' (1 or more times (matching the most amount possible))
$
before an optional \n, and the end of the string

How does "not regexp '^[aeiou].*[aeiou]$' " work? [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
The question is to 'query the list of CITY names from STATION that either do not start with vowels or do not end with vowels.' But the not here should work as "and" instead of "or"?
The problem is stated as "NOT(starting with a vowel) OR NOT(ending with a vowel)". The sql expression is saying "NOT(starting with a vowel AND ending with a vowel)", which is equivalent: https://en.wikipedia.org/wiki/De_Morgan%27s_laws
...except that the sql expression will produce the wrong result for city names that are just a single vowel character, because the regex will only match values when there are at least two characters.
You regex should be
(^[aeiou])|([aeiou]$)
Right now regex will only match if it start and ends with a vowel, while you want to say, start with vowel and it doesn't matter what is after, or it doesn't matter what is at the begining as long as it ends with a vowel.

REGEXP in MYSQL isn't working for full word search all time [duplicate]

This question already has answers here:
What special characters must be escaped in regular expressions?
(13 answers)
What is a word boundary in regex?
(13 answers)
Closed 2 years ago.
I've a table like this,
values
-------------------
male,female
PHP 30
PHP (30)
PHP ($30),CSS ($20)
PHP {$30},CSS {$20}
PHP [$30],CSS [$20]
PHP (€30),CSS (20)
I've prepared the sql like this,
SELECT mytable.values FROM mytable WHERE mytable.values REGEXP '[[:<:]]PHP ($30)[[:>:]]'
It should match one row (4th), but it's not working.
It's also not working with
() / {} / [] or any types of symbols like $ / €
I want to mention here that,
MYSQL LIKE isn't the right thing for me I think, because it won't work if we want to match male.
REGEXP is working for PHP 30 here and it's working for only strings.
Could anyone please inform me what will be the best solution to match the exact word or sentence?
Thanks in advance.

how to take first 3 character from a string using PHP [duplicate]

This question already has answers here:
MySQL Select Query - Get only first 10 characters of a value
(3 answers)
Truncate a string to first n characters of a string and add three dots if any characters are removed
(20 answers)
Closed 6 years ago.
I need to take only three characters from the string stored in MYSQL and output must be the first 3 character and the login date of customer
I am beginner kindly help me to code in PHP.
SELECT LEFT(string , 3) , logindate FROM tbl;
Hope this will help you.

Is there any function in MySQL for Regex Replace? [duplicate]

This question already has answers here:
How to do a regular expression replace in MySQL?
(13 answers)
Closed 6 years ago.
I have a table which needs stores some name and i need to replace a few characters before comparing them with another string
For instance, My table data is
abc
ghi:dki
ioe dsa
i read a string from user, which is of the form abc, ghi-dki, ioe-dsa. ie, all blankspaces, multiples spaces and symbols are converted to a hyphon(-). Now i need to compare. something like
SELECT MYCOLUMN FROM MYTABLE WHERE {Converted MYCOLUMN} = 'ghi-dki'
Can someone help me for figuring out which MySQL function can do it?
You can't do a regex replace in MySQL, but you can do a match.
SELECT mycolumn FROM tablename WHERE mycolumn REGEXP Replace('ghi-dki', '-', '^[\s:_-]*$');
Note: I didn't completely fill out the symbols character set, you'll have to add whatever you're using.