Community
    • Login

    Find all . between the start of the line and the first occurence : and find all " " between the start of the line and the first occurence :

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 379 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.
    • Long-Manith SREYL
      Long-Manith SREY
      last edited by

      Hi,

      Here is the data I currently have (“before” data):

      tokenized files: "toto.properties"
      spring.flyway.tata: "classpath:/xxxx/oracle"
      spring.flyway.toto: "classpath:/xxxx/oracle"
      spring.flyway.tata: "EN"
      spring.flyway.schemas: "OWNEN"
      spring.flyway.titi.aper: "APLEN"
      spring.flyway.titi.aplr: "AP"
      spring.flyway.titi.user: "APL"
      db.url: "jdbc:oracle:thin:@.fr.pop.intra:12232/1"
      

      Here is how I would like that data to look (“after” data):

      I have two needs
      1-> i would like to find all . between the start of the line and the first occurence ":"
      2->i would like to find all " " between the start of the line and the first occurence ":"
      

      So the result shoule be this way
      6ba12f6c-7399-4f03-8383-8b206720ced4-image.png

      To accomplish this, I have tried using the following Find/Replace expressions and settings
      (?:^|\G(?!^))[^.]\K.(?=.?: )
      The problem is notepad++ give me also this result
      fc5fd3ed-97fd-467b-b254-5305128cd226-image.png
      5d13b10c-304c-495a-9495-29d49d396adb-image.png

      Could you please help me to find the right expression?

      Thank in advance

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

        Hello, @long-manith-srey and All,

        From your post, we can merge your two needs, saying :

        From start of any line, I would like to find all space and dot characters which come before the first occurrence of the : symbol

        If so, I think that the following regex does the expected job !

        • Move to or open your file

        • If necessary, move to its very beginning with the Ctrl + Home shortcut ( IMPORTANT because of the negative look-ahead (?!\A) )

        • Open the Find or Mark dialog ( Ctrl + F / Ctrl + M )

        • SEARCH or MARK (?-s)(^|(?!\A)\G)[^:\r\n]+?\K[ .]

        • Untick all options

        • Select the Regular expression search mode

        • Click on the Find All in Current Document or on the Mark All button


        Of course, we’ll be able, to tune this regex, next time, in order to prevent from some matches or to get some additional matches, if any !

        On the other hand, the FR regex [ .] could be expressed differently if you need replacement and separate characters for the space and dot chars !

        Best Regards

        guy038

        P.S. :

        Using the notation from this generic regex, we have :

        BSR = ^

        ESR = [^:\r\n]. Note that we could have used the ((?!:).)+? syntax, instead, but the former syntax is more simple !

        FR = [ .]

        So the alternate regex is (?-s)(^|(?!\A)\G)((?!:).)+?\K[ .]

        Long-Manith SREYL 1 Reply Last reply Reply Quote 3
        • Long-Manith SREYL
          Long-Manith SREY @guy038
          last edited by

          @guy038
          Thank you so much*It’s perfect :)

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