LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 03-11-2004, 10:42 AM   #1
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Rep: Reputation: 15
S*[t-r]+[ing]?g


Hi

Does anyone knows some library in linux for searching for format strings or whatever it is called

For example:

Suppose I want to search for a substring in another string startin with a letter X and then some numbers

So I use X[0-9]+ or X*[0-9]+ etc.

??
 
Old 03-11-2004, 10:47 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Those are called regular expressions.

man regexp

will give you an overview of how they work, even tho this is meant for use inside C or C++ code. Any perl book, or basic unix book has a section on regular expressions.
 
Old 03-11-2004, 11:01 AM   #3
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Original Poster
Rep: Reputation: 15
ok
thnx a lot
 
Old 03-11-2004, 11:23 AM   #4
Strike
Member
 
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
What language are you coding in? We can't point you to a regexp library without knowing that.
 
Old 03-12-2004, 02:24 PM   #5
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Original Poster
Rep: Reputation: 15
I use C/C++
 
Old 03-12-2004, 03:33 PM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
For regular expression in C, see "man regcomp".
 
Old 03-12-2004, 05:55 PM   #7
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Original Poster
Rep: Reputation: 15
regcomp or regexp ??
 
Old 03-12-2004, 07:24 PM   #8
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
there is also 'prce', perl compatible regular expressions if you are more comfortable w/ those. and it's 'man regex' for POSIX regex's
 
Old 03-12-2004, 07:55 PM   #9
gr33ndata
Member
 
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Original Poster
Rep: Reputation: 15
What about LEX
Can I use LEX with strings instead of files

ie. yyin = some string instead of fopen("somefile","r");
 
Old 03-12-2004, 08:22 PM   #10
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
If you could it really wouldn't be worth the trouble — the POSIX regexp functions are quite easy to use.

Alex
 
Old 03-13-2004, 06:15 AM   #11
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Quote:
Originally posted by gr33ndata
regcomp or regexp ??
You need both regcomp() and regexec().
regexp is the struct they use.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mv ing contents of dirs timberwolf5480 Linux - Newbie 2 04-15-2005 11:38 PM
problem untar-ing fatblueduck Linux - Software 3 08-10-2004 06:35 AM
cd,ing to directory texasjailer Linux - Newbie 1 06-17-2004 01:45 PM
chmod ing - Help needed randelld Linux - General 5 04-09-2004 11:54 AM
just a quicky...(su-ing) salparadise Linux - Newbie 2 01-24-2003 05:40 PM


All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration