• Login
Community
  • Login

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

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 395 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.
  • J
    John Blue
    last edited by Apr 25, 2025, 1:39 PM

    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!

    P 1 Reply Last reply Apr 25, 2025, 1:55 PM Reply Quote 1
    • P
      PeterJones @John Blue
      last edited by PeterJones Apr 25, 2025, 1:56 PM Apr 25, 2025, 1:55 PM

      @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
      J 1 Reply Last reply Apr 25, 2025, 2:03 PM Reply Quote 1
      • J
        John Blue @PeterJones
        last edited by Apr 25, 2025, 2:03 PM

        @PeterJones, thank you so much!

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