I use BBEdit all the time. Some of its most powerful features are multi-file search 

and replace, and the ability to do GREP searching. GREP comes from the UNIX 

pattern-matching utility. You can use patterns to find text that matches 

particular kinds of characters.



Here's some basic info on GREPping:



. matches any char

# any digit

^ beginning of line

$ end of line



Use brackets for matching sets and ranges:



[xyz] any character x,y,z

[^xyz] any char but x,y,z

[a-z] any character from a - z



Use backslash characters to match non-printing characters:



\t Tab

\r Line Break (return)

\n Unix line break (line feed)

\f Page Break (form feed)

\x The charaxter x, unless x is one of the digits 0-9



Use repetition to match a series of characters:



P* matches 0 or more P's

P+ matches 1 or more P's

P? matches 0 or 1 P's



P can be the letter P or a wildcard or a range or a special character.



Use grouping to remember sub-patterns so that you can use 

them in replacement patterns:



& matches the entire matched pattern

(P) matches the sub pattern p

\1  \2 \n matches the nth pattern bracketed by () 



P can be a literal character, a wildcard, a range pattern or a special character.



to match white space made of one or more spaces and tabs, use 



[ \t]+



to match single words in quotes use:



"[A-Za-z]+"



to match any text in quotes, use



"[^"]+"



to find html links of the form



<A HREF="http://www.foo.com/www/.html">hot text</A> 



use this pattern:



<A[ \t]+HREF="([^"]+)">(.+)</A>



in replacement strings, \1 holds the URL and \2 holds the hot text 



Here are some patterns I use:



Sometimes I like to use Netscape bookmark files as regular HTML pages. You don't

have to remove the "last modified" lines, but they annoy me. So, search and replace 

for the following GREP pattern. Leave the replace box empty, so each instance is deleted.



[ \t]+ADD_DATE=+"[^"]+"+[ \t]+LAST_VISIT=+"[^"]+"+[ \t]+LAST_MODIFIED=+"[^"]+"



You can GREP search for incomplete URLs - say some URLs are missing "http" - search for 



<A[ \t]+HREF="([^http"]) 



To find urls with no http and no directories in the path (^/ means no /'s)



<A[ \t]+HREF="([^http:"])+([^/])+([.html]) 



To find incomplete urls with folders in the path and no http reference



<A[ \t]+HREF="([^http:"])+([/])+([.html])



----------



I had a list of names, some were 



Bob Jones

and some were

Jones, Bob



To get them all in the same order (first name then last name), I searched for 



^([a-z])+,+(.)+\r



in english: "find a beginning of a line ^, a series of letters ([a-z]), plus 

a comma +, plus anything else +(.), plus a carriage return +\r"



and replaced with 



\2+ +\1+\r



Where \2 holds the first name, add a space, \1 holds the last name, then add a carriage return.



To get even fancier, 



^([a-z][a-z0-9]*)+,+[ \t]+([a-z ][a-z0-9 \.]*)



finds last name plus a comma plus first name(s) and initials



replace with 



\2 \1



to swap last and first 



------------



to convert a plain text outline to nested lists:



search for A. and replace it with the open ordered list tag



find \rA\.+[ \t]

replace with

\r<OL TYPE=A>\rA\.+[ \t]



do the same for 1., a., i. - so now all your opening tags are in place



now to put in your list element tags, search for any number (#) or letter (.) 

preceded by a return (\r) and followed by a dot (\.) and a space or tab ([ \t])



find \r+.+\.+[ \t]



replace with 



\r<li>+.+\.+[ \t]



which will give you the <li> tags and retain the original outline numbers. (so you can see them 

together and make sure the nested lists are done properly)



now all you have to do is put in the closing elements for the various lists. i have not 

figured out a way to automate that process. let me know if you do! when everything looks right, 

nuke out the A., a., etc. with this:



find \r<li>+.+\.+[ \t]



replace with 



\r<li>





-----------



finding email addresses:

search for 

('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$')



(any combination of characters, plus an @ sign, plus any chars, plus a dot, plus any other chars)

(thanks to Micah for that one!)