PDA

View Full Version : ooh ooh I just did my first regular expression inside an SQL statement


Nav
11-04-2003, 20:49:50
sorry geek moment.

:nervous:

REGEXP '^[^a-z]'

Sean
11-04-2003, 21:22:11
Is that part of SQL91 or is it MySQL/Postgres/SQL Server/Oracle specific?

Sean
11-04-2003, 22:16:42
I’m an idiot. SQL/92.

Sean
11-04-2003, 22:19:48
And I must be a bigger idiot than I first thought, because I can’t find anything like the HTML or CSS specs for SQL.

Sir Penguin
11-04-2003, 22:37:38
Anything that's not not a to z?

SP

Sean
11-04-2003, 22:39:44
Match a string that starts with anything that isn’t a lowercase English letter.

I think.

Nav
11-04-2003, 22:40:08
http://www.mysql.com/doc/en/Regexp.html

Sean
11-04-2003, 22:42:14
. matches newlines? Ouch. Python does that, but only with re.DOTALL set.

Sean
11-04-2003, 22:47:51
And in Perl with /s.

Nav
11-04-2003, 22:50:24
SP, that would be stupid. ;)
the first ^ means from the beginning

and I just used 'LIKE 'a%'' to match english letters

oh yes and it worked.. http://www.gighit.com/artists.php?d=list

Sean
11-04-2003, 22:53:35
Ah. That’s much simpler than LIKE '0%' OR LIKE '1%' OR LIKE…etc.

Sean
11-04-2003, 22:54:10
Hmm. The link says 0-9, but as we see, the regex (deliberately) matches [^a-z], not [0-9]. Not actually confusing, but I am a pedantic bastard.

Nav
11-04-2003, 23:01:55
well if there's a way of properly denoting misc. characters and numbers please let me know. :)

Sean
11-04-2003, 23:02:59
You already have it! [^a-z]! Why, it’s clear as day.

Nav
11-04-2003, 23:05:30
I meant in the descriptive link on the page, it was pointless putting the expression in the link, I just did something like this..

if ($letter=="0-9") {
$search=" REGEXP '^[^a-z]'";
}

Sean
11-04-2003, 23:08:14
Yeah, I know, I was joking :). I mean I suppose Other would technically be better, but it also takes up more space and is slightly confusing. It’s fine as it is.

BTW, have you any experience with Invision Board (http://www.invisionboard.com/)? It seems to be utterly fantastic, but you never can tell.

Nav
11-04-2003, 23:16:18
I had a look at it, decided not to use it, there were to many around at the time I last looked and I decided just to use phpBB

Although now I'm tempted after the lack of and shite admin controls in phpBB, and the horrible default template...

Sean
11-04-2003, 23:18:54
I was never that impressed by phpBB, because pretty much all the boards that use it look the same. That’s a sure sign of not being easy to customise.

Nav
11-04-2003, 23:25:18
a-ha, the admin cp isn't under sub-folder called admin! (I had conflicts with phpbb on my server)

it looks good, I'll probably give it a try.

Sir Penguin
12-04-2003, 00:06:52
Originally posted by Nav
SP, that would be stupid. ;)
the first ^ means from the beginning

I plead guilty of spending more time on mathematical logic than on REs. :o

SP

LoD
12-04-2003, 18:51:22
Originally posted by Nav
I had a look at it, decided not to use it, there were to many around at the time I last looked and I decided just to use phpBB

Although now I'm tempted after the lack of and shite admin controls in phpBB, and the horrible default template...

phpBB sucks! tForum (http://www.tforumhacks.com) rules!
:nervous:

Nav
14-04-2003, 12:55:04
yeah completely. Go to the forum creators homepage and you get an access error message on their forum. :rolleyes: