Jump to content


Photo

Gregex Regular Expression Dll


  • Please log in to reply
18 replies to this topic

#1 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 08 June 2006 - 09:45 AM

Yeah, yeah, I've been working on this for a very long time. And by working I mean forgetting that I ever started working on it and finally getting around to finishing the documentation. Some people have been bugging me, so here it is, all done and everything. It can be found on the DLLs page of my website. I've only tested it in GM 6.1, but I don't see any reason why it shouldn't work with other versions.
  • 1

#2 Timmo

Timmo

    GMC Member

  • New Member
  • 558 posts
  • Version:GM:HTML5

Posted 08 June 2006 - 10:14 AM

I still didn't get ti how to use it, and when and where to use it?
  • 0

Posted Image Posted Image


#3 Smarty

Smarty

    GMC Member

  • GMC Elder
  • 7522 posts
  • Version:GM:Studio

Posted 08 June 2006 - 11:56 AM

I still didn't get ti how to use it, and when and where to use it?

Think of it as a library for advanced search (and replace) routines for strings.

A few examples I can think of:
  • Extracting relevant data from text files that are in a specific format
  • As the search routines return arrays of results, it's very convenient to index elements out of a single string
  • Easier and extended pre-formatting of output strings (inserting user variables)
  • Building a parse routine, where human input needs to be interpreted by the application (e.g. typing in an English sentence and the computer distilling your intention)
This is a great addition to the string functions that currently exist in Game Maker. The complexity of these routines wouldn't have made an efficient solution in GML.

The documentation is nicely formatted, although I'm afraid that many members would require more examples on the regular expressions. Especially the sub-expressions can be difficult to grasp:

(\d+)\s+(\w*) = "Find a string where a number is followed by a space and optionally a word. List that string, list all numbers from that string and list all words from that string."
  • 0

#4 SleeK GeeK

SleeK GeeK

    The Biggest And The Best

  • New Member
  • 769 posts

Posted 08 June 2006 - 11:57 AM

@Timmo

Regular Expressions are patterns of strings or numbers. They are wildcards like things. For eg, *.exe is an example of wildcard, where * can be replaced by anything, but it should end with .exe. But its not just wildcards, it goes beyond that. But its good enough to consider it as a string that follows a specific pattern. You may use it to check the validity of an email format.

EDIT : Smart has already given a good example above, i didnt see it while posting.

Regards,
SleeK GeeK.

Edited by SleeK GeeK, 08 June 2006 - 11:59 AM.

  • 0

#5 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 08 June 2006 - 03:19 PM

Regular expressions are basically the best thing we have to parse data and get results. Almost every other programming language has some kind of Regular Expression functionality, including JavaScript on webpages. And now that Yourself has made this DLL, GameMaker has Regular Expression ability as well.

For example, you can take any date in the same format as January 22nd, 2006 and get its individual parts with this regular expression pattern:

([a-zA-Z]+?) ([0-9]+?)(?:nd|st|th|rd), ([0-9]{4})

The first result (except for index 0, which is the entire match) will be the month name, the second would be the date (just the number, but extending the closing parentheses there to after the th) would get all of it), then the 3rd would be the 4-digit year.

Basically, Regular Expression (along with the correct programming) allow a computer to take information and decipher its meaning better than any other routines can.

Great DLL, Yourself. I'm pretty sure I'll find a use for this soon.

-IMP :P ;)

Edited by IceMetalPunk, 08 June 2006 - 03:23 PM.

  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#6 Null

Null

    GMC Member

  • New Member
  • 67 posts

Posted 10 June 2006 - 06:29 AM

Indeed, they are the most efficient utility for searching and manipulating parts of strings based upon syntax rules. They are so effective that some languages have support directly built-in for them.
This is a great extension for Game Maker. It's obviously superior to its current string manipulation functions. Also, we can be assured of its integrity as it is coming from Boost. :P
(Great documentation, by the way.)
  • 0
www.tysonc.net
Want to load models from Anim8or into your games? Use my export plug-in for Anim8or v0.95 Updated as of 4.14.07!
Want to learn Game Maker's 3D? Read my tutorials

#7 midgitman

midgitman

    GMC Member

  • New Member
  • 9 posts

Posted 10 June 2006 - 03:34 PM

excelent dll yourslelf but horrible timing
i just wrote an entire regexp and web scraper dll in c++!
oh well i did a few quick speed tests and mine seems to run a little faster with the functions i tested

EDIT web"scraper"

Edited by midgitman, 10 June 2006 - 10:02 PM.

  • 0

#8 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 10 June 2006 - 04:32 PM

oh well i did a few quick speed tests and mine seems to run a little faster with the functions i tested


Then release it. I'd like to know what a "webscaper" DLL does.
  • 0

#9 midgitman

midgitman

    GMC Member

  • New Member
  • 9 posts

Posted 10 June 2006 - 07:40 PM

a webscraper is a program that takes html source and parses it into raw data and in the case of my program turns forums such as the gmc into a more organized rss feed
i cant release my dll atleast not yet because its part of a commercial product and the gm version is just for easy testing before i make an actual gui and feed agitator

but back to your dll i havent noticed any bugs yet and il probably continue to use it for anything to complex for my regexp engine(wich i will hopefully release the gm compatable version)
  • 0

#10 databot

databot

    admin of moonlight games

  • New Member
  • 309 posts

Posted 10 June 2006 - 08:29 PM

I have had a go with gregex, it is another fantastic masterpiece by Yourself.
Very fast and a great way to validate data from the user, a server and many other locations (such as XML files).
I must go and code now.
  • 0
Completed:
Scrip - Command line engine in the palm of your hands Get it Here
XML - XML simplified

#11 Ravotus

Ravotus

    GMC Member

  • GMC Member
  • 327 posts

Posted 11 June 2006 - 02:43 AM

Ah, so you decided to go with boost after all. Great job on the dll. You should port more of the boost library to GM ;)

Edited by Ravotus, 11 June 2006 - 02:43 AM.

  • 0

#12 DtD

DtD

    Owner of DtD Software

  • New Member
  • 207 posts

Posted 12 June 2006 - 06:34 PM

Yes Finnally!!!!

I've been waiting for this for a while, for thoose who want to learn Regex, here is a fantastic book:
Mastering Regular Expressions by Jeffrey E. F. Friedl(ISBN: 0-596-00289-0) Published by O'REILLY

Edited by DtD, 12 June 2006 - 06:35 PM.

  • 0

#13 takua108

takua108

    GMC Member

  • GMC Member
  • 582 posts

Posted 15 June 2006 - 05:43 AM

Excellent job. Just what I've been waiting for.

Some more examples of regular expression usage are:

To make sure an e-mail address is really an email address (if you're connecting to a MySQL table in an online game and changing settings or whatnot via the client),

-Or-

If an IP address is really an IP address (for connecting on multiplayer games)
  • 0

#14 takua108

takua108

    GMC Member

  • GMC Member
  • 582 posts

Posted 27 June 2006 - 05:53 AM

Excuse the double-post...but one useful feature of Regular Expressions you forgot to mention is that in the pattern you can include
(?i)
to make your search case-insensitive. It took me several minutes to walk down the hall, find my book, and look for the correct section, so I thought I'd post it here. No wonder my profanity filter didn't work >_>

Also, I absolutely love this engine after having time to play around with it. I'll probably release this language filter-in-progress as an example, because (outside of the manual) there's no examples for this great DLL yet.
  • 0

#15 Timmo

Timmo

    GMC Member

  • New Member
  • 558 posts
  • Version:GM:HTML5

Posted 17 February 2007 - 08:39 PM

if i want to get data what is after = and it ends linebreak then what should the pattern look like?
  • 0

Posted Image Posted Image


#16 Porfirio

Porfirio

    GMC Member

  • GMC Member
  • 1209 posts

Posted 19 February 2007 - 04:37 PM

I love RegExp, i have being using it allot on JavaScript, and in PHP too althought the php implementation is ugly compared with the JavaScript one, maybe because of the prototyping in js <_<

Nice Dll
  • 0

#17 deformed thought

deformed thought

    GMC Member

  • GMC Member
  • 133 posts
  • Version:GM7

Posted 30 January 2010 - 06:12 PM

You should probably use a different place to post your file since the website tried to launch a trojan at me.
  • 0

#18 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 15 March 2010 - 11:59 PM

@deformed thought: Me, too. But Yourself's website (rather than the old blog) works without trouble: http://gm.ultimatepr...?page=downloads

@Timmo: I know you posted that reply three years ago, but in case you see it (or someone else also wants to know)... The pattern for something after '=' and before a line break would be: "=(.*?)$". To make sure it's not an empty string, you'd just replace * with + to get: "=(.+?)$".

-IMP ;) :)
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#19 Wins Vega

Wins Vega

    GMC Member

  • New Member
  • 21 posts

Posted 05 March 2011 - 11:11 AM

Yeah, yeah, I've been working on this for a very long time. And by working I mean forgetting that I ever started working on it and finally getting around to finishing the documentation. Some people have been bugging me, so here it is, all done and everything. It can be found on the DLLs page of my website. I've only tested it in GM 6.1, but I don't see any reason why it shouldn't work with other versions.


Wow, Man, it's just helped me with my hometask!! ) Thank you.
  • 0