1. Regular expressions
- Posted by ChrisB (moderator) Jun 25, 2009
- 1046 views
Hi
I have never used regular expressions before. I have used some simple greps.
Previously, if I have wanted to search a file for a particular string, I have opened and loaded the file, used find and match with each of the lines, and have not been unhappy with the speed or flexibility.
Should I instead be using the eu regex now? Is there an advantage to this for simple searches? One of the comments in the docs is that it is a large subjuct. Is there an advantage to me learning it?
Chris
2. Re: Regular expressions
- Posted by mattlewis (admin) Jun 25, 2009
- 1049 views
Hi
I have never used regular expressions before. I have used some simple greps.
Previously, if I have wanted to search a file for a particular string, I have opened and loaded the file, used find and match with each of the lines, and have not been unhappy with the speed or flexibility.
Should I instead be using the eu regex now? Is there an advantage to this for simple searches? One of the comments in the docs is that it is a large subjuct. Is there an advantage to me learning it?
Regular expressions probably won't be much of a benefit for simple searches. You're probably better off using the built in match() or find() functions. Regular expressions are more useful once you start using wildcards, or if you want to validate that data take a particular form.
For instance, suppose that I have some database records whose primary keys are all uuids, represented as lowercase text, without any dashes (this is an actual situation, BTW). To validate that I have a valid list of comma separated ids, I can use this expression:
"^(?:[0-9a-f]{32},)+$"It verifies that each id is exactly 32 characters, is only numbers and lowercase a-f, and that it's followed by a comma. It also makes sure that there is no other text either before or after the list.
Matt
3. Re: Regular expressions
- Posted by Tom Jun 25, 2009
- 1037 views
Take a look at the article on Regex
http://openeuphoria.org/wiki/euwiki.cgi?EuGuide%20Regular%20Expressions
If you run into any questions, I will revise the wiki.
Tom
4. Re: Regular expressions
- Posted by ChrisB (moderator) Jun 25, 2009
- 1052 views
Hi that wiki entry is very good. Thanks to both.
There should be an entry in the wiki / mini guides to find it, and a link from the manual to that wiki page.
Thanks
Chris
5. Re: Regular expressions
- Posted by DerekParnell (admin) Jun 25, 2009
- 1041 views
There should be an entry in the wiki / mini guides to find it
and a link from the manual to that wiki page.
Coming soon to a EuDoc near you
6. Re: Regular expressions
- Posted by jeremy (admin) Jun 26, 2009
- 1020 views
- Last edited Jun 27, 2009
Hi that wiki entry is very good. Thanks to both.
Yes, Tom has been doing a nice job adding more docs to Euphoria. Thanks Tom.
Jeremy