atw: Fwd: Searching for special characters in the Open Office Find dialog.

  • From: Stuart Burnfield <slb@xxxxxxxxxxxxxx>
  • To: austechwriter@xxxxxxxxxxxxx
  • Date: Mon, 24 Jan 2011 10:53:45 +0800 (WST)

> That $ lets me locate a hard line break but "$ "
> (dollar sign, space) fails to find one followed by
> a space on the start of the next line.

You're wondering, "Why are there two symbols $ and \n to represent a line 
break, and why does $ work only some of the time?"

These cover two different situations in which you want to include a line end in 
a search:

atw\n means "find the 4-character string "atw\n", that is atw followed by the 
ASCII newline character"
atw$ means "find atw at the end of a line". The $ is a sort of logical 
at-the-end-of-a-line. It doesn't include the actual \n character in the found 
string.

You can see the difference if you replace the found string with another string.

Generally, use $ for "one line at a time" searches--that is, when you want to 
search for something that falls within one line. 

Use \n if you want to search for something that spans two lines. In other 
words, you're treating the file simply as one long line or stream of 
characters, and the string that you're searching for happens to include the 
ASCII newline character.

Incidentally, you could also use "^ ". This would be much more efficient if you 
simply want to search for a space at the start of a line. However, if you want 
to remove the line break in this situation, you would have to find "\n " and 
replace it with " ".

There are some good resources on the net for understanding regular expressions. 
Ask away if you have questions.

Stuart
**************************************************
To view the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field (without quotes).

To manage your subscription (e.g., set and unset DIGEST and VACATION modes) go 
to www.freelists.org/list/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts:

  • » atw: Fwd: Searching for special characters in the Open Office Find dialog. - Stuart Burnfield