সোমবার, ৩০ মার্চ, ২০২০

Notepad ++ Tricks

Thanks for sharing this easy utility !
However, you can achieve it, quickly enough, using regular expressions, in search/replacement, within N++ ;-))
  • Open your file, in N++
  • Eventually, do a normal selection of the lines to be processed
  • Open the Replace dialog ( Ctrl + H)
  • Type in the regex ^\h*\d+ , in the Find what: zone
  • Leave the Replace with: zone EMPTY
  • If you did a selection, tick the In selection option. Otherwise, tick the Wrap around option
  • Select the Regular expression search mode ( IMPORTANT )
  • Click on the Replace All button

Note that this regex is, simply, an approximation of what that small utility does ! Indeed, this program :
  • Considers, only, the usual latin digits ( with Unicode value, from \x{0030} to \x{0039} ) as numbers to be deleted, instead of all Unicode numbers or similar, of any language !
  • Considers the first dot character ( . ), located right after a number, as a character to be deleted, too !
  • Considers all possible Unicode White space character ( except for the New Line character, \x{0085} ) , between the End of Line characters of the previous line and the numbers, of the current one, as characters which have to be deleted , as well. Refer, for that topic, to :
http://www.unicode.org/Public/UCD/latest/ucd/PropList.txt

So, assuming you would add a line-break, at the very beginning of your file, an exact search regex could be :
(\r\n|\r|\n)\K[^\S\x85]*[0-9]+\.?
Just for information, this regex :
  • First, the part (\r\n|\r|\n) tries to match some End of line character(s)
  • Then, the \K syntax reset the regex engine search process and position
  • Now, the part [^\S\x85]* finds the longest sequence, possibly empty, of White Space characters, different of \x{0085}
  • After, the part [0-9]+ simply looks for the longest non-empty range of classical digits
  • Finally, the syntax \.? searches a possible literal dot

Remark :
The part [^\S\x85] is difficult enough to understand : this negative class of characters [^...] represents a single character, which is DIFFERENT from, BOTH :
  • Any Unicode NON-Space character ( \S )
  • The New Line character ( \x{0085} )

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন