Menu

Custom defined Lang: Regex for Numbers?

2007-09-09
2012-11-13
  • Nobody/Anonymous

    Hi is it possible to use regex for numbers? Because in the scripting language PAWN you can write 1_000_000 instead of 1000000. But because of the '_' the number will not be recognized as a number. Is it somehow possible to do something like this?

     
    • pshute

      pshute - 2007-09-10

      I don't fully understand your question, but you could search for [0-9] to find a single digit.  See http://notepad-plus.sourceforge.net/uk/site.htm for notes about Notepad++'s regex support.

      The expression [0-9_]+ will match something like 100 or 1_000.  It gets more complicated if you also want to avoid matching the 1 in x1.

       
    • Nobody/Anonymous

      I know how to write regex.
      but my problem is with syntax highlighting. 1_000_000 is black instead of blue( color of the number) same goes with 0x015

       
      • pshute

        pshute - 2007-09-12

        Sorry, I completely misunderstood the question. I doubt you can fix it, but I don't know for sure.  I've never come across a language where you can do that before (not knowingly, anyway).  I guess you could just remove the underscores - they're optional, aren't they?

        Other than that, I think it would be a programming job.

         
        • pshute

          pshute - 2007-09-12

          Actually, I just entered some numbers into a file set to C language, and it made 1_000_000 all red.  It seems like it knows to treat underscores as digits for some languages.  It doesn't do it for VB, so it's language specific.  No idea whether this is configurable or is hard coded.