Simple RegExp function

D

drasko

Hi all. I need to code simple and fast int regexp_match(char *regexp,
char *string) function that will follow the expression regexp, and see
if there is a matching in the string. If there is, it will return 1
(TRUE). Are there some examples I can see, do you have ideas how to
start with this, and so on...

GNU C regexp is to big and complicated for me, it takes a lot of space
(i need this for the use in embedded system).

I'll appreciate any example I can follow. Just to make a start...

Thanks,
Drasko
 
M

Michael Mair

drasko said:
Hi all. I need to code simple and fast int regexp_match(char *regexp,
char *string) function that will follow the expression regexp, and see
if there is a matching in the string. If there is, it will return 1
(TRUE). Are there some examples I can see, do you have ideas how to
start with this, and so on...

GNU C regexp is to big and complicated for me, it takes a lot of space
(i need this for the use in embedded system).

I'll appreciate any example I can follow. Just to make a start...

There are several libraries out there; just evaluate them for your
purposes. Have a look at
http://arglist.com/regex/
and the links you can find there.

Apart from that: If you have very simple regular expressions in
mind, e.g. no replacing or referring: Roll your own. It is not that
hard.

Cheers
Michael
 
D

drasko

Michael said:
There are several libraries out there; just evaluate them for your
purposes. Have a look at
http://arglist.com/regex/
and the links you can find there.

Apart from that: If you have very simple regular expressions in
mind, e.g. no replacing or referring: Roll your own. It is not that
hard.

Cheers
Michael

Michael,
thanks. "Rolling my own" is exactly what I will try to do. It has to be
very simple. I just need some instructions, as I look where to begin.
Link you send is currently dead, but I will check it again tomorrow...
I just need some sources to give me starting ideas, and I hope this
will help.
 
J

John Devereux

drasko said:
Michael,
thanks. "Rolling my own" is exactly what I will try to do. It has to be
very simple. I just need some instructions, as I look where to begin.
Link you send is currently dead, but I will check it again tomorrow...
I just need some sources to give me starting ideas, and I hope this
will help.

In "The Practice of Programming", Kernighan and Pike develop a very
simple regular expression engine (in C) that may provide inspiration.
 
D

drasko

John said:
In "The Practice of Programming", Kernighan and Pike develop a very
simple regular expression engine (in C) that may provide inspiration.
Hi John,
thanks for the answer. I just saw it right now, and -- independently I
come to the same conclusion. This Kernighan/Pike example is the best I
stumbled upon and I used it to add more regular expression options...
But, maybe I will not be able to do it, because this code is so
condensely wrote, with heavy use of recursion, so as I am adding
features it complicates more and more. I'll try to finish it and maybe
post the results here...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top