regex mysql | regex mysql query | mysql regex function
- if you want to get the only text and numbers from varchar type field.
- first you have to create on one function in you database.
- than you fired query for using regexreplace();
Note :-
this function have three argument.
Syntax :- regexreplace(regex,text ,replace text);
- your regex.
- your text which you perform regex.
- your replace text.
Output :-
----------------------------------------------------------------------------------
| input | output |
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
| Located (please select) | Located please select |
----------------------------------------------------------------------------------
Function :-
DELIMITER $$
CREATE FUNCTION `regexreplace`(pattern VARCHAR(500),plaintext VARCHAR(500),replaceing VARCHAR(100))
RETURNS VARCHAR(500)
DETERMINISTIC
BEGIN
DECLARE repl VARCHAR(500);
DECLARE ch VARCHAR(1);
DECLARE i INT;
SET i = 1;
SET repl = '';
IF plaintext REGEXP pattern THEN
loop_label: LOOP
IF i>CHAR_LENGTH(plaintext) THEN
LEAVE loop_label;
END IF;
SET ch = SUBSTRING(plaintext,i,1);
IF NOT ch REGEXP pattern THEN
SET repl = CONCAT(repl,ch);
ELSE
SET repl = CONCAT(repl,replaceing);
END IF;
SET i=i+1;
END LOOP;
ELSE
SET repl = plaintext;
END IF;
RETURN repl;
END$$
DELIMITER ;
CREATE FUNCTION `regexreplace`(pattern VARCHAR(500),plaintext VARCHAR(500),replaceing VARCHAR(100))
RETURNS VARCHAR(500)
DETERMINISTIC
BEGIN
DECLARE repl VARCHAR(500);
DECLARE ch VARCHAR(1);
DECLARE i INT;
SET i = 1;
SET repl = '';
IF plaintext REGEXP pattern THEN
loop_label: LOOP
IF i>CHAR_LENGTH(plaintext) THEN
LEAVE loop_label;
END IF;
SET ch = SUBSTRING(plaintext,i,1);
IF NOT ch REGEXP pattern THEN
SET repl = CONCAT(repl,ch);
ELSE
SET repl = CONCAT(repl,replaceing);
END IF;
SET i=i+1;
END LOOP;
ELSE
SET repl = plaintext;
END IF;
RETURN repl;
END$$
DELIMITER ;
Query :-
SELECT description as 'Input',
regexreplace([^A-Za-z0-9 ]',description ,'') as 'Output'
FROM your table_name
where description REGEXP '[^A-Za-z0-9 ]';
regexreplace([^A-Za-z0-9 ]',description ,'') as 'Output'
FROM your table_name
where description REGEXP '[^A-Za-z0-9 ]';
Thanks for appreciation, I recognize you and your friend list for upcoming post.
ReplyDeleteGood coding index.
ReplyDeleteOracle training in btm
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteDevops Training in Chennai
Devops Training in Bangalore
Devops Training in pune
We are a group of volunteers and starting a new initiative in a community. Your blog provided us valuable information to work on.You have done a marvellous job!
ReplyDeletepython training in OMR
python training in Bangalore
python training in rajajinagar
Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries. I want to say thanks for great sharing.
ReplyDeleteAWS Training in chennai
AWS Training in bangalore
I was recommended this web site by means of my cousin. I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!
ReplyDeleteBlueprism training in marathahalli
Blueprism training in btm
Blueprism online training
Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..
ReplyDeleteBlueprism training in tambaram
Blueprism training in annanagar
Blueprism training in velachery
Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
ReplyDeleteData Science training in rajaji nagar | Data Science with Python training in chenni
Data Science training in electronic city | Data Science training in USA
Data science training in pune | Data science training in kalyan nagar
Outstanding blog post, I have marked your site so ideally I’ll see much more on this subject in the foreseeable future.
ReplyDeleteData Science course in rajaji nagar | Data Science with Python course in chenni
Data Science course in electronic city | Data Science course in USA
Data science course in pune | Data science course in kalyan nagar
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletejava training in jayanagar | java training in electronic city
java training in chennai | java training in USA
This is such a good post. One of the best posts that I\'ve read in my whole life. I am so happy that you chose this day to give me this. Please, continue to give me such valuable posts. Cheers!
ReplyDeleteangularjs Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
angularjs-Training in sholinganallur
angularjs-Training in velachery
Hello I am so delighted I found your blog, I really found you by mistake, while I was looking on Yahoo for something else, anyways I am here now and would just like to say thanks for a tremendous post. Please do keep up the great work.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
ReplyDeletedevops online training
aws online training
data science with python online training
data science online training
rpa online training
It's a wonderful post and very helpful, thanks for all this information about Java. You are including better information regarding this topic in an effective way.Thank you so much for your sharing...
ReplyDeleteAndroid Training in Chennai
Android Online Training in Chennai
Android Training in Bangalore
Android Training in Hyderabad
Android Training in Coimbatore
Android Training
Android Online Training
perde modelleri
ReplyDeletesms onay
Mobil ödeme bozdurma
nft nasil alinir
ankara evden eve nakliyat
trafik sigortası
dedektör
WEB SİTESİ KURMAK
Ask kitaplari
smm panel
ReplyDeleteSMM PANEL
iş ilanları
instagram takipçi satın al
hirdavatciburada.com
Https://www.beyazesyateknikservisi.com.tr/
servis
JETON HİLESİ