Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Regular Expressions (https://forums.graalonline.com/forums/showthread.php?t=134257341)

coreys 12-18-2009 08:25 AM

Regular Expressions
 
Every once in awhile I run across a situation where I wish I could use regular expressions in GS2. Since this is no trivial task to implement myself, not to mention it would most likely be slow if not done at a language level, it would be really nice if regular expressions were added into GS2.

Programmer 12-18-2009 01:19 PM

Quote:

Originally Posted by coreys (Post 1545150)
Every once in awhile I run across a situation where I wish I could use regular expressions in GS2. Since this is no trivial task to implement myself, not to mention it would most likely be slow if not done at a language level, it would be really nice if regular expressions were added into GS2.

I completely agree. I have also come across several situations where Regex would make my life so much easier. Seeing as how several libraries offer this in C++, it should not be so difficult to implement in GScript at all.

Immolate 12-18-2009 01:21 PM

Yeah, I support this.

coreys 12-23-2009 09:02 PM

Bump!
There's a couple things I hope to use regex for that would make my life so much better.
Better living through regular expressions! :D

fowlplay4 12-23-2009 09:36 PM

Could you show some theory usage of how it would work? I haven't touched regex before.

Crow 12-23-2009 09:44 PM

Lua syntax, it's from one of my WoW addons:
PHP Code:

msg gsub(msg"^|Hchannel:(%S+)|h%[([%d%.%s]*)([^%]]+)%]|h ""|Hchannel:%1|h" .. channelFormat .. "|h "); 

Basically, this replaces the display format of the channel escape sequence (WoW stuff) at the start of the string msg (if any escape sequence exists) with a predefined new format stored in channelFormat.
WoW channel escape sequences work like this:
PHP Code:

|Hchannel:CHANNEL_HERE|hCHANNEL_DISPLAY_NAME_HERE|

If you want to know some more details, either ask, or check out patterns on the Lua website. Also, as far as I know, Lua implements regular expressions a tad differently compared to other languages, so you might also want to check out the PHP documentation.

WhiteDragon 12-23-2009 09:44 PM

I've never needed regex for coding anything in Graal. Not to mention they can lead to some seriously inefficient code if you don't know what you are doing (e.g., when checking against a non-regular language, unlimited backreferences are an NP-complete problem).

DustyPorViva 12-23-2009 09:50 PM

I've ran into a couple situations where I really wish I had it. I think getstringkeys() is probably the most common.

coreys 12-23-2009 09:54 PM

I'm familiar with regular expressions as they're used in Python. They're a tad bit complicated to learn, but very useful for searching for patterns.

And inefficient code is always an issue, no matter what you do, so it's not really a reason to not support this. I personally could find good use for regex.

WhiteDragon 12-23-2009 10:12 PM

Quote:

Originally Posted by coreys (Post 1546611)
And inefficient code is always an issue, no matter what you do, so it's not really a reason to not support this. I personally could find good use for regex.

I'm just saying that regex is particularly complex and therefore more prone to inefficiencies.

coreys 12-23-2009 10:44 PM

Quote:

Originally Posted by WhiteDragon (Post 1546622)
I'm just saying that regex is particularly complex and therefore more prone to inefficiencies.

Yeah, but user error is user error, no reason not to have it :)

Loriel 12-24-2009 12:12 AM

Pft, who needs regexps when you could instead build some awesome parser combinator system.

WhiteDragon 12-24-2009 12:28 AM

Quote:

Originally Posted by Loriel (Post 1546641)
Pft, who needs regexps when you could instead build some awesome parser combinator system.

Whoever implements parsec first wins a cookie!

cbk1994 01-15-2010 11:07 PM

Bumping this because I just ran into a place where this would be perfect.

Loriel 01-16-2010 12:00 AM

Quote:

Originally Posted by Loriel (Post 1546641)
Pft, who needs regexps when you could instead build some awesome parser combinator system.

Bumping this too!!


All times are GMT +2. The time now is 11:32 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.