Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-20-2008, 06:08 AM   #16
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97

Ghostdog74, that was exactly my point about regular expressions being potentially too inclusive.

By matching only valid characters (or avoiding invalid characters) you reduce issues later.

Example, to search for test followed by any number(including zero) of any character (excluding spaces and \ characters), followed by a .iso:

sed -i.bak 's/test[^ \]*\.iso/test0123-new.iso/' test.vmx

As we only want to exclude spaces and \ characters, this is shorter than my previous example, while still only finding valid matches.


If you want to match a full stop you need to escape it (using \) EG: \.

Last edited by Disillusionist; 07-20-2008 at 06:15 AM.
Old 07-20-2008, 07:01 AM   #17
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
that's why my own preferred method is using fields and not worrying about regular expressions and its always the last field i want to change. well anyway, OP has got a solution, so it should be fine.


charachters, sed

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
Replacing "function(x)" with "x" using sed/awk/smth Griffon26 Linux - General 3 11-22-2006 10:47 AM
Using "sed" - a simple explanation needed midiox Linux - Newbie 2 04-03-2006 06:47 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
KPPP "Query Modem" returns empty fields ananya Linux - Hardware 2 02-21-2005 10:50 PM
KPPP "Query Modem" returns empty fields ananya Linux - Software 1 02-21-2005 10:39 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:17 PM.

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