|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
sed question, given a set of char's, replace char's not in the set
Hello, and thanks for taking time to read my question.
I would like to use sed, or "tr", to replace any invalid character with a <space>. My set of valid characters are a-z A-Z 0-9 ! " & , ( ) + ' ? = @ / . - If the line contains any characters not in the set listed above, I would like to replace each invalid one with a <space>. My attempt at this is: sed 's/[^a-zA-Z0-9!"&,()+\`?=\@;\/\.-]/ /g' but this will not quite do it. It does not do a one for one replace of bad characters. thank you for any advice |
|
#2
|
|||
|
|||
|
It seems to work for me...
Code:
$ echo 'a((:::c%%b' | sed 's/[^a-zA-Z0-9!"&,()+\`?=\@;\/\.-]/ /g' a(( c b $ |
|
#3
|
|||
|
|||
|
I'm not sure why it wasn't before, but I copied and pasted your exact text and it does work. This is my first attempt at using SED and I'm finding it a bit tricky to get the syntax down. Thank You for the assistance, much appreciated.
|
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > sed question, given a set of char's, replace char's not in the set |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|