Community
    • Login

    Either find or skip comma(s) inside parentheses

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 664 Views 1 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.
    • glossarG Offline
      glossar
      last edited by glossar

      Hi all,
      I need a regex that will find or skip comma(s) inside parentheses in a line - skipping is preferred.
      Searched and found a few for square brackets but, to my surprise, I can’t adjust them to parentheses: (?:[|(?!^)\G)[^,]]*\K,

      Ex:
      It should find the comma(s) in “(settlement, bargain, audit, cash)” and “(prompt, name, settling, ticket)” and skip the one in “day (time) of reckoning, (Börse) account” or the other way around, find the one in “day (time) of reckoning, (Börse) account” and skip the ones in parentheses: “settling (settlement, bargain, audit, cash) day, day of account, day (time) of reckoning, (Börse) account (prompt, name, settling, ticket) day (Br.),”

      Thanks in advance!
      glossar

      1 Reply Last reply Reply Quote 0
      • Terry RT Offline
        Terry R
        last edited by Terry R

        @glossar said in Either find or skip comma(s) inside parentheses:

        It should find the comma(s) in “(settlement, bargain, audit, cash)” and “(prompt, name, settling, ticket)” and skip the one in “day (time) of reckoning, (Börse)

        Your question is a bit vague. You don’t care which way, find or skip yet the method to do so would vary greatly. Since your Ex: suggested find within the parentheses that’s what I’ve done.
        Find What:(\(|\G)[^\),]*\K,

        Not sure where you intend going with this since you have an end goal in mind but haven’t provided that, not that it necessarily needs to be provided for a “Find” to work. It does sometimes help in getting the full story so we might be able to provide a different idea that works better.

        Sorry had to edit as was using the squares originally when attempting to decipher your regex.

        Good luck
        Terry

        glossarG 1 Reply Last reply Reply Quote 2
        • glossarG Offline
          glossar @Terry R
          last edited by

          @Terry-R said in Either find or skip comma(s) inside parentheses:

          ((|\G)[^),]*\K,

          Thank you so much, it works! :)

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

            Hello, @glossar, @terry-r and All,

            Some other regexes !

            • To match any non-empty single-line area, between ( and ) included, not containing any ,, use the regex

              • \([^(),\r\n]*\)
            • To match any non-empty single-line area, between ( and ) included, containing, at least, one ,, use the regex

              • (?-s)\([^(),\r\n]*,.+?\)
            • To match any non-empty single-line area, between ( and ) not included, not containing any ,, use the regex

              • \(\K[^(),\r\n]*(?=\))
            • To match any non-empty single-line area, between ( and ) not included, containing, at least, one ,, use the regex

              • (?-s)\(\K[^(),\r\n]*,.+?(?=\))

            Best regards,

            guy038

            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