PostgreSQL Regexp - Find records with single char

postgres regex examples
postgres regex special characters
postgres regex tester
postgres regex numbers only
postgresql regex example
postgres like not working
postgres regex capture group
postgres string starts with

I am trying to get from table all records, that have in column only one -.

select, ta.created from tol.order ta 
where similar to '%-{1}%' and ta.created > '2018-05-01'

But have no success.

For instance I should get all records with name like:


but NOT like


Thanks for any advise and help.

A non-regex way with PostgreSQL's built in function. See Array Function

SELECT, ta.created from tol.order ta 
WHERE (array_length(string_to_array(, '-'),1)-1) = 1 
    and ta.created > '2018-05-01'

PostgreSQL Regexp - Find records with single char, A non-regex way with PostgreSQL's built in function. See Array Function SELECT, ta.created from tol.order ta WHERE  Managed PostgreSQL Service for App Developers. Focus on Apps Not Infrastructure.

Have you tried sth like:

SELECT, ta.created from tol.order ta WHERE ~ $rxb$^[^-]*?-[^-]*$$rxb$ and ta.created > '2018-05-01';

Using regexps in PostgreSQL, Many are surprised to hear that PostgreSQL supports regexps at all. PostgreSQL's operators are generally aimed at finding whether a g option, returned three rows, with each row containing a single (one-character) array. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more PostgreSQL Regexp - Find records with single char

I would take the opposite approach and do a regex to exclude anything that had:

a hyphen: - followed by any characters (including none): .* followed by another hyphen: -

select, ta.created
from tol.order ta 
where !~ '-.*-' and ta.created > '2018-05-01

PostgreSQL REGEXP_MATCHES: Extracting Text Based on a Regex, This tutorial shows you how to use the PostgreSQL REGEXP_MATCHES() function to extract text according to a regular expression. The flags argument is one or more characters that control the behavior of the function. For example, i function returns a set of text, even if the result array only contains a single element. The following illustrates the syntax of the PostgreSQL REGEXP_MATCHES() function: REGEXP_MATCHES(source_string, pattern [, flags]) Arguments. The REGEXP_MATCHES() function accepts three arguments: 1) source. The source is a string that you want to extract substrings which match a regular expression. 2) pattern

PostgreSQL LIKE, You may find the customer in the customer table by looking at the first name column to see if The query returns rows whose values in the first name column begin with Jen and may be Underscore ( _ ) for matching any single character. Introduction. A regular expression is a set of characters in a specific sequence that helps identify the required correct input. We are going to take a look at regex and how to use them using different approaches or operators such as LIKE, NOT LIKE, and SIMILAR TO in addition to the tilde operator family such as ~, ~, !~, !~ which matches regular expressions in case sensitive and case

How to use Regex in SQL, Regex, or Regular Expressions, is a sequence of characters, used to search and _, Any single character (using LIKE and SIMILAR TO), c_, co, fico, pico for all entries that contain the word 'fire', you could use ~* 'fire' to find any row that  A string is said to match a regular expression if it is a member of the regular set described by the regular expression. As with LIKE, pattern characters match string characters exactly unless they are special characters in the regular expression language --- but regular expressions use different special characters than LIKE does.

MYSQL Regular Expressions (REGEXP) with Syntax & Examples, Regular Expressions help search data matching complex criteria. Let's suppose that we want to search for movies that start with a, b, c or d , followed by any metacharacter is used to match any single character in exception of a new line. 20 Best SQL (Database) Management Tools in 2020 [Free/Paid]. 9.4. String Functions and Operators. This section describes functions and operators for examining and manipulating string values. Strings in this context include values of the types character, character varying, and text.