
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Return a specific MySQL string using regular expressions
Let us first create a table −
mysql> create table DemoTable649 (Value text); Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable649 values('1903'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable649 values('9321010'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable649 values('983032023393'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable649 values('1234567892'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable649 values('989898989'); Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable649;
This will produce the following output −
+--------------+ | Value | +--------------+ | 1903 | | 9321010 | | 983032023393 | | 1234567892 | | 989898989 | +--------------+ 5 rows in set (0.00 sec)
Following is the query to return a specific MySQL string using regex −
mysql> select *from DemoTable649 where Value REGEXP '[0-9]{11}';
This will produce the following output −
+--------------+ | Value | +--------------+ | 983032023393 | +--------------+ 1 row in set (0.00 sec)
- Related Articles
- How to split a string using regular expressions in C#?
- How to extract numbers from a string using regular expressions?
- Remove Leading Zeroes from a String in Java using regular expressions
- How to remove consonants from a string using regular expressions in Java?
- How to remove vowels from a string using regular expressions in Java?
- MySQL Regular expressions: How to match digits in the string with d?
- Date validation using Java Regular Expressions
- Name validation using Java Regular Expressions
- Replace one string with another string with Java Regular Expressions
- Phone Number validation using Java Regular Expressions
- Zip Code validation using Java Regular Expressions
- How to extract data from a string with Python Regular Expressions?
- Extracting email addresses using regular expressions in Python
- JavaScript Regular Expressions
- Replace all words with another string with Java Regular Expressions

Advertisements