LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-01-2004, 08:38 AM   #1
MadCactus
Member
 
Registered: Jul 2003
Distribution: Slackware 9.1
Posts: 195

Rep: Reputation: 30
conditional replacment with regexps?


Hi,

Suppose I have some text with a whole load of a's and b's, how can I create a regexp to replace the a's with b's and the b's with a's?
 
Old 10-01-2004, 08:46 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
sed 's/a/-=-TMP-=-/g; s/b/a/g; s/-=-TMP-=-/b/g'

But I guess tr 'ab' 'ba' should work.

Yves.
 
Old 10-01-2004, 09:19 AM   #3
MadCactus
Member
 
Registered: Jul 2003
Distribution: Slackware 9.1
Posts: 195

Original Poster
Rep: Reputation: 30
Suppose I was using emacs though?
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab stops in emacs regexps King of Men Linux - Software 0 11-07-2005 11:39 AM
CASE conditional la_mafia63 Linux - General 3 07-24-2005 01:02 PM
c compound conditional steve_96 Programming 9 06-04-2005 07:17 PM
Webtrends replacment? swinchen Linux - Software 0 08-20-2004 08:01 AM
OS Conditional Defines kevin.cowley Programming 1 09-24-2003 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:17 AM.

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