Community
    • Login

    Need to find lines that are missing a comma at the end.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 5 Posters 2.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Alan KilbornA
      Alan Kilborn @Monarchia
      last edited by Alan Kilborn

      @Monarchia

      Try searching for [^,]$ after setting the Search mode to Regular expression.

      MonarchiaM 1 Reply Last reply Reply Quote 2
      • MonarchiaM
        Monarchia @Alan Kilborn
        last edited by

        @Alan-Kilborn Thank you for your response. I have tried both and neither has come up with anything worth noting… so I suppose the error is not due to the lack of a comma. Do you know of any way to perhaps search for the format of each line and accordingly isolate lines that don’t fit the usual format? I’m not sure if that request is within NP++'s capabilities.

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Monarchia
          last edited by Alan Kilborn

          @Monarchia

          Hm, well from the sample data we can maybe draw some conclusions…

          You might try a Mark operation using the following regular expression:

          (?-s)^".+?": ".+?",$

          It should turn the background of all lines red that conform to what seems to be your format.

          Note that this is fairly “loose” as I really have no idea what truly constitutes a valid line format that is accepted by whatever tool is using the file.

          MonarchiaM 1 Reply Last reply Reply Quote 3
          • MonarchiaM
            Monarchia @Alan Kilborn
            last edited by

            @Alan-Kilborn
            I used the Mark operation and did not find any matching results (There is a nonzero chance I did it wrong)

            I would like to provide more information about how the data is being utilized but struggle to describe how it is as I am not very experienced in this field. For what it’s worth, the information is being accessed by Minecraft and applied to specific text labels spread out through different areas of the game. Here’s another screenshot with more data that is (hopefully) more useful. Any ideas? Thank you for your help up to this point, by the way.

            094b852f-658a-4191-b28b-a2df93aeeee8-image.png

            PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Monarchia
              last edited by

              @Monarchia ,

              Your file format looks rather JSON-like. If the simple checks that @Alan-Kilborn has pointed out are not finding anything, you might try installing the JSONTools plugin which (IIRC) can do a syntax check on JSON, and might take you to the line where it’s wrong. If that doesn’t find it, then it’s probably not a syntax error, and it’s instead a data-error: ie, some valid JSON string is something that the minecraft engine cannot handle, hence your problem – but if that’s the case, we won’t be able to help you, because this is not a minecraft-modding forum.

              MonarchiaM 1 Reply Last reply Reply Quote 3
              • Alan KilbornA
                Alan Kilborn @Monarchia
                last edited by

                @Monarchia

                Offhand, I can’t see why the marking operation didn’t work for you. Of course, we’re just working from pictures, not actual sample text. Usually the first thing we do is ask for real text. This case seemed so simple, though… :-(

                1 Reply Last reply Reply Quote 2
                • MonarchiaM
                  Monarchia @PeterJones
                  last edited by

                  @PeterJones It is a JSON file, yes. I didn’t insert any characters or information that Minecraft is incapable of handling so I really feel as though it’s something vital that I accidentally deleted. I will install the plugin and see if it helps. Thank you for your assistance.

                  PeterJonesP 1 Reply Last reply Reply Quote 1
                  • PeterJonesP
                    PeterJones @Monarchia
                    last edited by

                    @Monarchia ,

                    The other thing you can do, if you have the original version of the JSON file, is to use the ComparePlus plugin and compare the old to the new, and thus see all the changes that were made. That might help you narrow down where the problem is.

                    1 Reply Last reply Reply Quote 2
                    • guy038G
                      guy038
                      last edited by guy038

                      Hello, @monarchia, @alan-kilborn, @peterjones and all,

                      Well, @monarchia, after using the Irfanview sofware with a recognition characters plugin and some minor ajustments, I was able to extract this text from your first image which can be transformed into this functional json block, below :

                      {
                       "narrator.position.object list": "Selected row element %s out of %s",
                       "narration.suggestion.tooltip": "Selected suggestion %d out of %d: %s (%s)",
                       "narration.suggestion": "Selected suggestion %d out of %d: %s",
                       "narration.button": "Button: %s",
                       "narration.button.usage.focused": "Press Enter to activate",
                       "narration.button.usage.hovered": "Left click to activate",
                       "narration.cycle button.usage.focused": "Press Enter to si~tc:~ to %s",
                       "narration.cycle~button.usage.hovered": "Left click to switc:~ to %s",
                       "narration.checkbox": "Checkbox: %s",
                       "narration.checkbox.usage.focused": "Press Enter to toggle",
                       "narration.checkbox.usage.hovered": "Left click to toggle",
                       "narration.recipe": "Reciple for %s",
                       "narration.recipe.usage": "Left click to select",
                       "narration.recipe.usage.miore": "Right click to show miore reclpes",
                       "narration.selection.usage": "Press up and down buttons to nove to another entry",
                       "narration.comqoonent~list.usage": "Press Tab to navigate to next element",
                       "narration.slider.usage.focused": "Press left or right keyboard buttons to change value",
                       "narration.slider.usage.hovered": "Drag slider to change value",
                       "narration.edit~box": "Edit box: %s"
                      }
                      

                      Now, @monarchia, try the following method to get all specific lines which do not have the right format :

                      • Open the Mark dialog ( Ctrl + M )

                      • Untick all box options

                      • SEARCH (?x-s) ^ \h* " .+? " : \x20 " .+ ? " , $ (*SKIP) (*F) | ^ .+

                      • Check the 2 options Bookmark line, and Purge for each search

                      • Select the Regular expression search mode

                      • Move to the very beginning of your json file

                      • Click on the Mark All button

                      • Now, hit the F2 key, repeatedly, to get the different lines which do not satisfy your format !

                      Remark the part \h*, at beginning of the regex, which could explain why the previous @alan-kilborn’s solution found nothing !


                      Running this regex against the json block above, previously copied in a new tab, should obviously mark the lines { and }, as well as the last data line "narration.edit~box": "Edit box: %s" which does not end with a comma character !

                      Best Regards,

                      guy038

                      PS :

                      Alan, in order to mark all lines not ending with a comma char, I suppose that the regex [^,\r\n]$ is a better bet !

                      1 Reply Last reply Reply Quote 3
                      • Mark OlsonM
                        Mark Olson @Monarchia
                        last edited by

                        @Monarchia
                        Looks like you got this fixed, but just wanted to chime in that JsonTools can indeed find the errors in your JSON file (as PeterJones mentioned), but you can also just turn on linting and then you can parse the JSON with any number of missing commas (as well as various other syntax errors) and pretty-print it as syntactically valid JSON.

                        If your JSON file had a truly preposterous number of such syntax errors (say on the order of hundreds of thousands), the linter would probably use a lot of memory though.

                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors