Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / Regular Expressions Plugin

Author
Message
Jeff032
16
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 15th Jul 2009 14:49 Edited at: 17th Jul 2009 02:05
I've decided to try to make a plugin to add support for regular expressions to DBPro, if anyone actually shows interest.

Attached is version 0.1 of the dll, here are the commands so far:
REGEX SET string - sets the regular expression being used
boolean REGEX IS MATCH(string) - returns whether the string matches the regular expression
integer REGEX MATCHES(string) - creates a list of all matches, and returns the number of items in the list
string REGEX GET MATCH(integer match#) - returns an item from the list created by REGEX MATCHES (starts at 1, not 0)
string REGEX GET GROUP(integer match#, string groupName) - returns the value of a named group

Please let me know what you think of it so far, if it doesn't work, etc.

-Jeff

[UPDATE]
I have added the ability to use named groups now, using the command:

string REGEX GET GROUP(integer match#, string groupName)

This is useful for parsing data that is in a form such as this:
{X:5,Y:11}{X:16,Y:2}...

See the 4th section of the sample program in the attached zip for an example of how to do this.

An updated version is attached to this post.
[/UPDATE]

Attachments

Login to view attachments
Profit
18
Years of Service
User Offline
Joined: 19th Feb 2006
Location: United States
Posted: 15th Jul 2009 17:38 Edited at: 15th Jul 2009 18:31
great!


tiresius
21
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 15th Jul 2009 21:55
That's cool!

I use basic regular expressions all the time to search for code at work "@[A-Z][0-99]" etc. etc. But that is searching an entire file (via TextPad). Can you list some uses of doing this for a single string?

I'm not a real programmer but I play one with DBPro!
Jeff032
16
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 17th Jul 2009 02:05
@Profit
Thanks

@tiresius
Hmm...I find it useful for parsing or validating input. Just recently I wanted a program to get data out of a website which was in the format "<li># word</li><li># word</li>...", where '#' is a number of an undetermined length, and 'word' is the data that I needed to grab. It was easy to do with a regular expression, using groups.

Speaking of groups, I had a small amount of free time, so I added support for getting the value of named groups now.

[b]see first post[b]

Login to post a reply

Server time is: 2024-05-19 22:43:41
Your offset time is: 2024-05-19 22:43:41