Author Topic: Searching by hex codes in text document  (Read 9670 times)

davek

  • Community Member
  • Posts: 8
  • Hero Points: -2
Searching by hex codes in text document
« 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?

MgFrobozz

  • Community Member
  • Posts: 14
  • Hero Points: 0
Re: Searching by hex codes in text document
« Reply #1 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).

davek

  • Community Member
  • Posts: 8
  • Hero Points: -2
Re: Searching by hex codes in text document
« Reply #2 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.

MgFrobozz

  • Community Member
  • Posts: 14
  • Hero Points: 0
Re: Searching by hex codes in text document
« Reply #3 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).
« Last Edit: November 04, 2011, 12:06:57 AM by MgFrobozz »

davek

  • Community Member
  • Posts: 8
  • Hero Points: -2
Re: Searching by hex codes in text document
« Reply #4 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.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Searching by hex codes in text document
« Reply #5 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.

davek

  • Community Member
  • Posts: 8
  • Hero Points: -2
Re: Searching by hex codes in text document
« Reply #6 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.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: Searching by hex codes in text document
« Reply #7 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.