SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: davek on November 03, 2011, 01:18:33 PM

Title: Searching by hex codes in text document
Post by: davek on November 03, 2011, 01:18:33 PM
I am looking for a certain hex pattern in a text document, specifically a carriage return and a linefeed. Should be easy. The search string I am using is \:h0d\:h0a. Why does SE 10 not return any occurances? The \:h is put in place by the additional options in the find window search field. Is that not the correct way to use this search field option? Eventually I want to search for carriage return and form feed, but I was testing the search by something I know would occur. Is there a different syntax for doing searches on hex values?
Title: Re: Searching by hex codes in text document
Post by: MgFrobozz on November 03, 2011, 08:25:25 PM
One way to do this: in the "Find" dialog, click one "Use:" and select "Regular expression (UNIX)". Then enter "\n" for newline (0x0d/0x0a, CF/LF).
Title: Re: Searching by hex codes in text document
Post by: davek on November 03, 2011, 08:41:13 PM
If I entered it correctly, this is what is in the search field "\n (0x0d/0x0a, CF/LF)". I also have Regular Expression checked. It does not find anything.
Title: Re: Searching by hex codes in text document
Post by: MgFrobozz on November 04, 2011, 12:03:27 AM
Enter only "\n" (include the back-slash, but do not include the quotation marks).

The rest of the text is my remark on what "\n" looks for ("CR" is short for "carriage return", which has hex value 0x0d, and "LF" is short for "line feed", which has hex value 0x0a).
Title: Re: Searching by hex codes in text document
Post by: davek on November 04, 2011, 12:46:45 PM
If I want to look for the sequence CR and FF (0x0d and 0x0c), what do I enter? Basically I need the syntax to look for any combination of hex characters.
Title: Re: Searching by hex codes in text document
Post by: Lee on November 04, 2011, 01:01:31 PM
To search for literal hexadecimal using Unix\Perl\SlickEdit regex syntax:
\x0D\x0A

Usually it is easier to use \n to match the line ending character(s).  This matches the current documents line endings, so it will match 0d0a for documents with Windows line endings, and 0a for Unix line endings.
Title: Re: Searching by hex codes in text document
Post by: davek on November 04, 2011, 01:08:31 PM
Thank you. Just searching for \0x0D\0x0A was what I needed. What does preceeding the string with the \:h do? I thought that meant to search for the hex characters.
Title: Re: Searching by hex codes in text document
Post by: Lee on November 04, 2011, 01:11:52 PM
\:h roughly translates to [0-9A-F]+, it matches a string that consists of valid hexadecimal characters.