• Login
Community
  • Login

Trim LDAP extract

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 3 Posters 1.5k 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.
  • O
    Olivier Chantraine
    last edited by Olivier Chantraine Jan 18, 2023, 1:09 PM Jan 18, 2023, 12:52 PM

    Hello,
    i need to remove every first (ex:CN=toto), from my ldap export.
    its easy if there is only one.
    but my extract containt sometime more.

    ex:
    CN=toto,CN=test,DC=contoso,DC=local

    and then, the replace option remove every CN.
    If i use the mark option, its ok, but i can’t remove marqued texte (or i dont find the option)

    Could you help me with that ?
    Thanks :)

    A O 3 Replies Last reply Jan 18, 2023, 1:12 PM Reply Quote 0
    • A
      Alan Kilborn @Olivier Chantraine
      last edited by Alan Kilborn Jan 18, 2023, 1:12 PM Jan 18, 2023, 1:12 PM

      @Olivier-Chantraine

      Your problem statement is a bit vague, but with my interpretation of it, I would try:

      Find: \A(?s)(.*?)(?-i)CN=\w+,
      Replace: ${1}
      Search mode: Regular expression

      1 Reply Last reply Reply Quote 2
      • A
        Alan Kilborn @Olivier Chantraine
        last edited by Jan 18, 2023, 1:14 PM

        @Olivier-Chantraine said in Trim LDAP extract:

        i can’t remove marqued texte (or i dont find the option)

        This option doesn’t exist because you can just use Replace instead.

        1 Reply Last reply Reply Quote 1
        • O
          Olivier Chantraine @Olivier Chantraine
          last edited by Olivier Chantraine Jan 18, 2023, 3:45 PM Jan 18, 2023, 3:44 PM

          @Olivier-Chantraine said in Trim LDAP extract:

          Hello,
          i need to remove every first (ex:CN=toto), from my ldap export.
          its easy if there is only one.
          but my extract containt sometime more.

          ex:
          CN=toto,CN=test,DC=contoso,DC=local

          and then, the replace option remove every CN.
          If i use the mark option, its ok, but i can’t remove marqued texte (or i dont find the option)

          Could you help me with that ?
          Thanks :)

          Sorry, i will try to be clear,
          i have a csv with multiple line (txt line)
          each line start with CN=
          CN=toto,CN=test,DC=contoso,DC=local
          CN=tota,OU=test,DC=contoso,DC=local
          CN=tata,OU=test2,DC=contoso,DC=local
          CN=tAto,CN=test2,DC=contoso,DC=local

          i want to remove the first “CN=text,”
          with option mark text, i use :

          ^CN.*?,
          

          and it work well (for marking only)
          but , if i replace, the regex erase all “CN=text,” in the same line

          P 1 Reply Last reply Jan 18, 2023, 4:32 PM Reply Quote 0
          • P
            PeterJones @Olivier Chantraine
            last edited by PeterJones Jan 18, 2023, 4:33 PM Jan 18, 2023, 4:32 PM

            @Olivier-Chantraine said in Trim LDAP extract:

            and it work well (for marking only)
            but , if i replace, the regex erase all “CN=text,” in the same line

            That’s because after the substitution, the next CN=text, is the first CN=text, on the line, and it will match again.

            I think what you want is
            FIND = (?-s)^CN=.*?,(.*)$
            REPLACE = ${1}

            That will delete the first CN=..., on each line, leaving the rest of the line intact.

            ----

            Useful References

            • Please Read Before Posting
            • Template for Search/Replace Questions
            • Formatting Forum Posts
            • Notepad++ Online User Manual: Searching/Regex
            • FAQ: Where to find other regular expressions (regex) documentation
            O 1 Reply Last reply Jan 19, 2023, 8:12 AM Reply Quote 3
            • A
              Alan Kilborn
              last edited by Alan Kilborn Jan 18, 2023, 6:06 PM Jan 18, 2023, 6:06 PM

              @Olivier-Chantraine

              From the revised explanation of the problem, I can see why you liked the Mark idea (that wouldn’t work). :-)

              1 Reply Last reply Reply Quote 2
              • O
                Olivier Chantraine @PeterJones
                last edited by Jan 19, 2023, 8:12 AM

                @PeterJones said in Trim LDAP extract:

                @Olivier-Chantraine said in Trim LDAP extract:

                and it work well (for marking only)
                but , if i replace, the regex erase all “CN=text,” in the same line

                That’s because after the substitution, the next CN=text, is the first CN=text, on the line, and it will match again.

                I think what you want is
                FIND = (?-s)^CN=.*?,(.*)$
                REPLACE = ${1}

                That will delete the first CN=..., on each line, leaving the rest of the line intact.

                ----

                Useful References

                • Please Read Before Posting
                • Template for Search/Replace Questions
                • Formatting Forum Posts
                • Notepad++ Online User Manual: Searching/Regex
                • FAQ: Where to find other regular expressions (regex) documentation

                Ty, its working :)

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