473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Checking regex pattern validity

Is there a function like IS_VALID_REGEX() to check whether a pattern is
valid (i.e. it compiles)? I'm storing a list of regex patterns in a
table. It would be nice to be able to add a CHECK constraint to ensure
that all the regexes are valid.

If there isn't any, can I suggest Postgres add one? Although I know this
can probably be done in plpgsql using exception handling, or done in
plperl or plruby.

--
dave
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
2 2605
David Garamond <li***@zara.6.isreserved.com> writes:
Is there a function like IS_VALID_REGEX() to check whether a pattern is
valid (i.e. it compiles)? I'm storing a list of regex patterns in a
table. It would be nice to be able to add a CHECK constraint to ensure
that all the regexes are valid.


... CHECK (('' ~ pattern) IS NOT NULL) ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #2
Tom Lane wrote:
David Garamond <li***@zara.6.isreserved.com> writes:
Is there a function like IS_VALID_REGEX() to check whether a pattern is
valid (i.e. it compiles)? I'm storing a list of regex patterns in a
table. It would be nice to be able to add a CHECK constraint to ensure
that all the regexes are valid.


... CHECK (('' ~ pattern) IS NOT NULL) ...


Not exactly what I wanted, but close enough. Thanks!

However, what if only want to accept invalid regex patterns? Or what if
invalid pattern should be converted to NULL automatically? I'd still
vote for a function...

--
dave

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: unndunn | last post by:
I'm trying to design a regular expression that matches (using preg_match()) when a string is a well-formed Email address. So far I have this: /^+@+\.{2,4}$/i I got that from...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
1
by: Craig Kenisston | last post by:
Hi, I need to write a function that should behave like the SQL's "like" operator on a list of words. I was wondering if I can use Regex directly to do this job. But I've been reading about...
9
by: Whitless | last post by:
Okay I am ready to pull what little hair I have left out. I pass the function below my String to search, my find string (a regular expression) and my replace string (another regular expression)....
8
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the...
4
by: shonend | last post by:
I am trying to extract the pattern like this : "SUB: some text LOT: one-word" Described, "SUB" and "LOT" are key words; I want those words, everything in between and one word following the...
8
by: sherifffruitfly | last post by:
Hi, I've been searching as best I can for this - coming up with little. I have a file that is full of lines fitting this pattern: (?<year>\d{4}),(?<amount>\d{6,7}) I'm likely to get a...
0
by: vmysore | last post by:
I am trying to get all the columns selected within a SQL query (including the sub selects). When the code hits matcher.find(). i get the following exception: Exception in thread "main"...
10
by: Brent | last post by:
I have a list of company names (say, IBM, Corning, General Motors, and another 5,000 of them). If I take a body of text, a news article, for instance, and I want to see which company names...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.