n00b problem with regular expressions
1
Name:
Anonymous
2010-03-30 17:43
sed -i -n 's/[23]/[213]/g' myfile.txt
I want to replace "[23]" with "[213]" This is not working because of the brackets being interpreted as a regular expression. Is there a escape character to avoid this?
2
Name:
Anonymous
2010-03-30 17:44
Err,
sed -i -n 's/[23]/[213]/' myfile.txt
3
Name:
Anonymous
2010-03-30 17:47
[code] tags, junior.
4
Name:
Anonymous
2010-03-30 17:49
ZOMG RTFM IHBT
5
Name:
Anonymous
2010-03-30 17:52
I found how to do it.
sed -i -n 's/[23\]/[213\]/' myfile.txt
6
Name:
Anonymous
2010-03-30 18:45
>>5
you should probably escape all non-alphanumeric characters just to be sure.
7
Name:
Anonymous
2010-03-30 19:26
>>6
you should probably escape all alphanumeric characters too just to be sure.
8
Name:
Anonymous
2010-03-30 19:53
>>7
\Y\o\u\ \m\e\a\n\ \l\i\k\e\ \t\h\i\s\?
9
Name:
Anonymous
2010-03-30 20:08
10
Name:
Anonymous
2010-03-30 20:36
>>9
EXPERT CONTROL CODE NOTICER
11
Name:
Anonymous
2010-03-30 22:18
\Y\o\u\ \m\e\a\n\ \l\i\k\e\ \t\h\i\s\?
[code] \N\o, \l\i\k\e \t\h\i\s.[/code[
12
Name:
Anonymous
2010-03-30 22:49
14
Name:
Anonymous
2011-02-03 6:58