Community
    • Login

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

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 900 Views 2 Watching
    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 Offline
      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 Online
        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 Offline
          John Blue @PeterJones
          last edited by

          @PeterJones, thank you so much!

          1 Reply Last reply Reply Quote 1

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors