LinuxQuestions.org
Review your favorite Linux distribution.
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 08-14-2003, 10:49 AM   #1
WeNdeL
Member
 
Registered: Oct 2002
Location: At my desk...
Distribution: RedHat, Fedora, Ubuntu
Posts: 344

Rep: Reputation: 30
Question Regular Expression Help


I am having some trouble rebuilding a database or two via a mysql dump. The problem is that some non-escaped single quotes have made their way into certain fields.

So I am writing a script that will fix this... here is my sed command:

sed "s/\([A-Z|a-z|0-9]\)'\([A-Z|a-z|0-9]\)/\1\\\'\2/" $1 > /tmp/$1


This basically changes anything like "abc's" to "abc\\'s" or "123's" to "123\\'s". Now the problem is that this sed command only alters one occurrence within each line. There are multiple occurrences in each line...

So how do I make this alter multiple occurrences found in each line?

Last edited by WeNdeL; 08-14-2003 at 10:50 AM.
 
Old 08-14-2003, 11:08 AM   #2
WeNdeL
Member
 
Registered: Oct 2002
Location: At my desk...
Distribution: RedHat, Fedora, Ubuntu
Posts: 344

Original Poster
Rep: Reputation: 30
wow... rocket science we have here...

make the command look like this:

sed "s/\([A-Z|a-z|0-9]\)'\([A-Z|a-z|0-9]\)/\1\\'\2/g" $1 > /tmp/$1

notice the global "g" that was added...
 
  


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
Need help with regular expression aecaudel Programming 6 11-04-2005 06:28 AM
Need help with Regular Expression subaruwrx Linux - Newbie 6 09-04-2004 08:48 PM
Anyone know regular expression? ahhua Linux - Software 1 12-04-2003 09:13 AM
Regular Expression slizadel Programming 4 07-28-2003 06:16 AM
regular expression gumby Programming 3 07-15-2003 01:13 PM


All times are GMT -5. The time now is 09:41 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