how to search/replace text in mutliple files?

Trevor Smith trevor at haligonian.com
Wed Feb 11 13:13:30 UTC 2004


Man, I am completely at a loss how to use a regex to search for whitespace.

I *want* to search and replace some complex strings in multiple HTML files but 
I can't even successfully SEARCH -- forget about the replace!!

Do regular expressions not actually work to find whitespace?!? I can't make 
them work, although the regex editor in Kate seems to do the job, when I copy 
even a simple regex that it produces to the command line for use with grep or 
egrep, they match exactly nothing.

For example, a test file named "test.file" containing:

some words
some other words

produces matches with:

grep 'e w' test.file

but NO matches with:

grep 'e\sw' test.file
egrep 'e\sw' test.file
grep 'e[\s]w' test.file
etc.

Now, that's fine if the file I'm searching has ONLY one space, but the WHOLE 
purpose of regexes is to allow me to search flexibly. I want to search for 
different lengths of whitespace, etc., but since I can't even search for ONE 
whitespace character successfully, I'm unable to expand my regex.

Any help? (Eventually I was going to build the regex to look for 
space/tab/newline characters.)

-- 
 Trevor Smith    |    trevor at haligonian.com 





More information about the users mailing list