473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple RegExp function

Hi all. I need to code simple and fast int regexp_match(ch ar *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

Jul 17 '06 #1
4 2467
drasko schrieb:
Hi all. I need to code simple and fast int regexp_match(ch ar *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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jul 17 '06 #2

Michael Mair wrote:
drasko schrieb:
Hi all. I need to code simple and fast int regexp_match(ch ar *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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
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.

Jul 17 '06 #3
"drasko" <dr************ **@gmail.comwri tes:
Michael Mair wrote:
>drasko schrieb:
Hi all. I need to code simple and fast int regexp_match(ch ar *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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.

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.

--

John Devereux
Jul 18 '06 #4
John Devereux wrote:
"drasko" <dr************ **@gmail.comwri tes:
Michael Mair wrote:
drasko schrieb:
Hi all. I need to code simple and fast int regexp_match(ch ar *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
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
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.

--

John Devereux
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...

Jul 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
39328
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1: domything() And the regexp search assuming no case restriction would be,
0
1806
by: Chris Croughton | last post by:
I'm trying to use the EXSLT regexp package from http://www.exslt.org/regexp/functions/match/index.html (specifically the match function) with the libxml xltproc (which supports EXSLT), but whatever I do gets errors. The examples use namespace regExp, but the supplied files use regexp, I've got it so that it at least doesn't complain...
4
7456
by: Jon Maz | last post by:
Hi All, I want to strip the accents off characters in a string so that, for example, the (Spanish) word "práctico" comes out as "practico" - but ignoring case, so that "PRÁCTICO" comes out as "PRACTICO". What's the best way to do this? TIA,
3
1588
by: mehdi_mousavi | last post by:
Hi folks, Consider the following JavaScript function: function removeParam(str, name) { var rgx = new RegExp('(' + name + '=\\w*)|(' + name + '=\\w*;)'); rgx.global = true; rgx.ignoreCase = true; var matches = rgx.exec(str); if(matches == null)
7
3427
by: Csaba Gabor | last post by:
I need to come up with a function function regExpPos (text, re, parenNum) { ... } that will return the position within text of RegExp.$parenNum if there is a match, and -1 otherwise. For example: var re = /some(thing|or other)?.*(n(est)(?:ed)?.*(parens) )/ var text = "There were some nesting parens in the test"; alert (regExpPos (text,...
24
6294
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
6
2260
by: runsun pan | last post by:
Hi I am wondering why I couldn't get what I want in the following 3 cases of re: (A) var p=/(+-?+):(+)/g p.exec("style='font-size:12'") -- // expected
1
1562
by: DougJrs | last post by:
Good Morning, I am trying to write a simple function that would grab the "errorId" parameter and then display a message when the page loads. I basically have a login page (login.asp) that if the login fails the user is directed page to the login page with an errorId parameter (login.asp? errorId=1). I wrote the javascript below to grab...
7
1712
by: VUNETdotUS | last post by:
How can I get the text after matching string is found: var str = "1111>AAAA<2222>BBBB<3333>CCCC"; if(str.indexOf("2222>")){ //how to get "BBBB" value following my "2222>" but before "<3333" or any < sign? }
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.