I frequently work in rather large (30+ meg) text based data files and I need to find every line that has a specific character in a specific position and make a few manual updates to those lines. There are only a rather small number (45 or so) lines that have the given character in the position but I can't seem to get a regex to work to search for it. For example, sometimes I need to search for "G" in position 25 and other times I need to search for "CNW" in positions 15, 16, 17. What regular expression can I use to find these?

  • Sandeep, thanks for the link but that doesn't seem to work for me. Using notepad++ v7.5.6 in the find dialog I have the search mode set to Regular Expression but /^.{13}0/ results in "Find: Can't find the text "/^.{13}0/" " It looks like it's not doing the search based on the regex but rather just searching for that text. Admittedly (and obviously), I'm new to using regex in Notepad++ – Scott Jun 27 '18 at 14:48
  • Ctrl+F
  • Find what: ^(?:.{24}G|.{14}CNW).*$
  • UNcheck Match case
  • check Wrap around
  • check Regular expression
  • DO NOT CHECK . matches newline
  • Search in document


^               : beginning of line
  (?:           : start non capture group
    .{24}G      : 24 any character but newline then the letter G
   |            : OR
    .{14}CNW    : 14 any character but newline then the letters CNW
  )             : end group
  .*            : 0 or more any character but newline
$               : end of line
  • Perfect! Thank you very much. I marked your response as useful but since I just registered, it doesn't count yet so please know I am very grateful for your answer! (and the easy to understand explanation!) – Scott Jun 27 '18 at 16:00
  • @Scott: You're welcome, glad it helps. – Toto Jun 27 '18 at 16:22
  • @Scott: You have not enough reputatin to upvote, but you can mark the answer as accepted, see: superuser.com/help/someone-answers – Toto Jun 27 '18 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.