1. Regular expressions

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

new topic     » topic index » view message » categorize

2. Re: Regular expressions

ChrisB said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Regular expressions

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: Regular expressions

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Regular expressions

ChrisB said...

There should be an entry in the wiki / mini guides to find it

Done

ChrisB said...

and a link from the manual to that wiki page.

Coming soon to a EuDoc near you blink

new topic     » goto parent     » topic index » view message » categorize

6. Re: Regular expressions

ChrisB said...

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu