LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 01-10-2009, 08:57 AM   #1
onesikgypo
Member
 
Registered: Jun 2008
Posts: 56

Rep: Reputation: 15
Need help with bash + regex


Hi, im trying to extract some text from a string via regex, the string is like this:

bla bla<abc><def><ghi>...

i only require everything before the first <, and there may be an infinite number of <text> after the string i require.

ive tried using

string=`expr match "$string" '\(.*\)<'`

however ive had no luck


any help would be greatly appreciated.
 
Old 01-10-2009, 09:22 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
string=${string%%<*}
 
Old 01-10-2009, 10:08 AM   #3
onesikgypo
Member
 
Registered: Jun 2008
Posts: 56

Original Poster
Rep: Reputation: 15
thats an alot easier solution, thankyou
 
  


Reply



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
bash replace all matches of regex substring in string nickleus Linux - General 3 04-30-2011 11:08 AM
Regex in bash? BeholdMyGlory Linux - Newbie 4 01-10-2009 08:32 AM
bash: better way to delete files not matching a regex? pbhj Programming 8 10-15-2007 03:05 PM
regex with sed to process file, need help on regex dwynter Linux - Newbie 5 08-31-2007 05:10 AM
BASH RegEx file name parsing Hewson Linux - General 7 04-27-2007 05:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:28 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
Open Source Consulting | Domain Registration