SQLite3 Regular Expressions and Schema Constraints - regex

In a SQLite3 CREATE TABLE statement, can I use a regular expression to enforce a particular constraint? Specifically, I am trying to require that an inputted URL is valid. I know there are other ways of doing this besides using regular expressions, but because of the structure of my project, this is the method I need.

You can use regular expressions only after you've installed a user-defined REGEXP function; SQLite doesn't have one by default.
But if you have it, you can use REGEXP also in a CHECK constraint.

Related

Clojure: Definitions of basic terms

In Clojure context, some define the term form as “any valid code,” and some as “any valid code that returns a value.” So both the numeral 1729 and the string Hello! is a form. Likewise (fn is not a form. Is an undefined symbol, say my-val, a form?
What is the difference between an expression and a form?
What is the difference between an expression and a function?
There are some good answers to this question at Are Lisp forms and Lisp expressions same thing?
The key thing to think about is that there are different points in the lifecycle. We start with text "(+ 1 2)" which is then read into Clojure data (a list containing a symbol and two numbers). Often in Lisps "expression" is used to mean the former and "form" is used to mean the latter. In practice, I do not find that people are at all consistent with this usage and often use both terms for both things.
If you take "form" to mean "something which can be evaluated", then 1729 or "Hello!" or the symbol my-val are all forms. When my-val is evaluated it is resolved in the current namespace, perhaps to a function instance, which is invokable. Functions are really important only at evaluation time, when they can be invoked.
Another interesting aspect are macros, which allow you to create new syntax. Note that macro expansion happens after reading though, which means that while you can create new syntax, it still must follow some basic expectations that are encoded into the reader (namely that invocations follow the pattern (<invokable> <args...>)). Note that macros work on read but unevaluated forms (data, not text) and must produce new forms.
What is the difference between an expression and a form?
In my opinion form in a context of Clojure is something a compiler deals with. Some forms are valid expressions while others are "special" forms (i.e. macros).
What is the difference between an expression and a function?
Any function is an expression.
Is an undefined symbol, say my-val, a form?
I would say it is a valid expression (hence form) which yields to a compile time exception.
Likewise (fn) is not a form
It seems like you are referring to some source, where this was declared, could you provide a link?

C++ How does boost spirit parantheses work

In boost spirit there are parantheses which can be used to indicate that a part of grammar is going to be repeated
A>>(B>>C)*
I want to use this concept to write a generic scenario controller but I have no idea how they implemented that the parantheses are implicitly creating some object around B and C
Well, it seems you're asking about the attributes of rules. Spirit can propagate the parsed content automatically to data types. Each parser, also *(...), defines rules how those data types should look like. You'll find it as "attribute propagation" in the documantation.
Here are two interesting links for this subject:
http://boost-spirit.com/home/articles/attribute_handling/attribute-propagation-and-attribute-compatibility/
http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/abstracts/attributes.html

Reusing a character class in a regular expression

In order to keep a regular expression more brief, is there a shorthand way to refer to a character class that occurs earlier in the same regular expression?
Example
Is there a way to shorten the following:
[acegikmoqstz##&].*[acegikmoqstz##&].*[acegikmoqstz##&]
Keep in mind that regex features are dependant on the language being used.
With Java, you can do this:
[acegikmoqstz##&](?:.*[acegikmoqstz##&]){2}
But that's all, with java you can't refer to named subpattern.
With PHP you can do that:
(?(DEFINE)(?<a>[acegikmoqstz##&]))\g<a>(?:.*\g<a>){2}

referencing a type from within an xsd pattern

I want to recognize all of my servers over my office network. They have a particular naming pattern which only I use. I've defined it in a simpleType.
Now I was told I have to filter my servers from a list of full DNS names (like www.bla.moo.oneofmyservers.foo.loo). My naming strategy has a length limit. I would have simply put it inside a *mystrategy* if not for that.
Is there a way to reference my type from within a pattern definition?
It didn't work when I wrote *mytype*.
Assuming that what you're asking is something like this:
I have a pattern and I've used it as a constraining facet in a simple type; now, I want to make another type, and for maintenance purposes, I wish to somehow reference that pattern, so that I don't have to maintain it in two different places...
The answer is no, you can't. Constraining facets in XSD are not referenceable entities; nor types are referenceable within constraining facets.

regular expression to rename pointer variables

I have this much
Code snippet:
int *filePointer;
float *valPtr;
*valPtr = 5.6;
filePointer = ∑
I would like to replace all pointer variables as follows, for example
*filePointer have to be converted to *filePointer_p.
filePointer have to be converted to filePointer.
valPtr have to be converted to valPtr_p
How can I do it using Regular Expression.
It sounds to me like you might be asking how to use regular expressions as a generic tool to rename all pointer variables in source code. I am assuming that the provided snippet is just an example.
If my understanding of your goal is correct, it is not possible to do that with regular expressions. A regular expression would not be able to determine reliably from the context if a variable is a pointer. Consider, for example, a=b;. a and b could be pointers or they could be most anything else. A regular expression by itself would not be able to determine that.
The first is simply:
s/\*filePointer/*filePointer_p/g
Not sure what you're second is on about? But if you're basically out to rename filePointer, then you should be able to simply do:
s/filePointer/filePointer_p/g
on the assumption that there aren't any other variables or context that contain the text filePointer in a different context.
For 1, try s/\*filePointer/*filePointer_p/g.