• Login
Community
  • Login

Either find or skip comma(s) inside parentheses

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 295 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.
  • G
    glossar
    last edited by glossar Feb 28, 2021, 6:25 PM Feb 28, 2021, 6:24 PM

    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
    • T
      Terry R
      last edited by Terry R Feb 28, 2021, 6:58 PM Feb 28, 2021, 6:56 PM

      @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

      G 1 Reply Last reply Feb 28, 2021, 7:25 PM Reply Quote 2
      • G
        glossar @Terry R
        last edited by Feb 28, 2021, 7:25 PM

        @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
        • G
          guy038
          last edited by guy038 Feb 28, 2021, 7:38 PM Feb 28, 2021, 7:36 PM

          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
          2 out of 4
          • First post
            2/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors