Community
    • Login

    How to find a comma that is embedded in a string?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 79 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.
    • John BlueJ
      John Blue
      last edited by

      I have a Json data file like below:

      {
      	"customers": 
      	{
      		[
      			{
      				"cus_id": "1234",
      				"first_name": "John",
      				"last_name": "Smith",
      				"add_1": "2369 Lake St",
      				"add_2": "",
      				"city": "New York",
      				"state": "NY",
      				"zip": "10003",
      				"company": "Joe Supplier, Inc."
      			},
      			{
      				"cus_id": "3456",
      				"first_name": "Mary",
      				"last_name": "Hope",
      				"add_1": "208 Mountain View Way",
      				"add_2": "APT-2",
      				"city": "San Francisco",
      				"state": "CA",
      				"zip": "93102",
      				"company": "Sunnywood Logistics, LLC."
      			}
      		]
      	}
      }
      

      I just want to find the embedded (,) in the company value. How can I do that in Notepad++?

      Thank you!

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

        @John-Blue ,

        Using Notepad++'s “regular expression” mode in your search, you can search for "company": "[^"]*\K, – which will search for the key’s name, and the opening quote mark, then search for any non-quotemark until it finds the comma. The \K just before the , means it will only select what’s after the \K when you click find, rather than selecting everything from the start of "company".

        However, you should probably read our FAQ: Parsing and Editing JSON with regex is a bad idea

        ----

        Useful References

        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        John BlueJ 1 Reply Last reply Reply Quote 1
        • John BlueJ
          John Blue @PeterJones
          last edited by

          @PeterJones, thank you so much!

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