Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

n00b problem with regular expressions

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?

Name: Anonymous 2010-03-30 17:44

Err,
sed -i -n 's/[23]/[213]/' myfile.txt

Name: Anonymous 2010-03-30 17:47

[code] tags, junior.

Name: Anonymous 2010-03-30 17:49

ZOMG RTFM IHBT

Name: Anonymous 2010-03-30 17:52

I found how to do it.
sed -i -n 's/[23\]/[213\]/' myfile.txt

Name: Anonymous 2010-03-30 18:45

>>5
you should probably escape all non-alphanumeric characters just to be sure.

Name: Anonymous 2010-03-30 19:26

>>6
you should probably escape all alphanumeric characters too just to be sure.

Name: Anonymous 2010-03-30 19:53

>>7
\Y\o\u\ \m\e\a\n\ \l\i\k\e\ \t\h\i\s\?

Name: Anonymous 2010-03-30 20:08

>>7
lol enjoy your \n

Name: Anonymous 2010-03-30 20:36

>>9
EXPERT CONTROL CODE NOTICER

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[

Name: Anonymous 2010-03-30 22:49

>>9
That's the joke.

Name: Anonymous 2011-02-03 6:58

Don't change these.
Name: Email:
Entire Thread Thread List