Community
    • Login

    CSS not working when I add it to multiple files using the Regular expression mode

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    21 Posts 3 Posters 763 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.
    • dr ramaanandD
      dr ramaanand @guy038
      last edited by

      @guy038 merci beaucoup!

      1 Reply Last reply Reply Quote 1
      • Alan KilbornA
        Alan Kilborn @guy038
        last edited by

        @guy038

        It seems like your solution is a long route when the OP was looking for a short route.

        Much shorter is what I guessed at and seemingly what the OP was already doing:

        • select the replacement text in the editor
        • press Ctrl+f
        • swap Find what and Replace with (using the button)
        • overwrite Find what
        • “escape” any ( or ) characters in Replace with
        • execute Replace in Files
        1 Reply Last reply Reply Quote 1
        • guy038G
          guy038
          last edited by guy038

          Hello, @alan-kilborn and All,

          Alan, I grant you : your idea is more direct and simpler than mine ;-))


          However, let’s suppose that an OP is working on a Lisp program and that he wants to insert this Lisp module which converts any roman number into its decimal equivalent number

          For instance, in Lisp, with the program below and the question (trad 'MCMXCV), it would return 1995 ( I do not know this language and I just suppose that it’s true ! )

          (de trad (Z) (cond  ;                \* ROMAN number -> DECIMAL number *\
          					(( eq Z 'I) 1)
          					(( eq Z 'V) 5)
          					(( eq Z 'X) 10)
          					(( eq Z 'L) 50)
          					(( eq Z 'C) 100)
          					(( eq Z 'D) 500)
          					(( eq Z 'M) 1000)
          					((atom Z) (trad (explodech Z)))
          					((null (cdr Z)) (trad (car Z)))
          					((< (trad (car Z)) (trad (cadr Z)))
          					(- (trad (cdr Z)) (trad (car Z))))
          					(t (+ (trad (car Z)) (trad (cdr Z)) )) ))
          

          No doubt that using my mehtod will be safer !!

          Note that I included a LISP comment, which begins with a semi-colon, adding a comment with a C-like syntax in order to place anti-slashes in my example !

          After aplying the regex S/R :

          • SEARCH ([()\\])|\R

          • REPLACE ?1\\\1:\\r\\n

          against this List module, you would get the text below, which could be correctly inserted, as it, in a larger Lisp program !

          \(de trad \(Z\) \(cond  ;                \\* ROMAN number -> DECIMAL number *\\\r\n					\(\( eq Z 'I\) 1\)\r\n					\(\( eq Z 'V\) 5\)\r\n					\(\( eq Z 'X\) 10\)\r\n					\(\( eq Z 'L\) 50\)\r\n					\(\( eq Z 'C\) 100\)\r\n					\(\( eq Z 'D\) 500\)\r\n					\(\( eq Z 'M\) 1000\)\r\n					\(\(atom Z\) \(trad \(explodech Z\)\)\)\r\n					\(\(null \(cdr Z\)\) \(trad \(car Z\)\)\)\r\n					\(\(< \(trad \(car Z\)\) \(trad \(cadr Z\)\)\)\r\n					\(- \(trad \(cdr Z\)\) \(trad \(car Z\)\)\)\)\r\n					\(t \(+ \(trad \(car Z\)\) \(trad \(cdr Z\)\) \)\) \)\)\r\n
          

          Best Regards,

          guy038

          Well, this example is a bit “far-fetched”, but, as I knew that the Lisp language abuses parentheses, I couldn’t resist ! LOL

          Alan KilbornA dr ramaanandD 2 Replies Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @guy038
            last edited by

            @guy038 said in CSS not working when I add it to multiple files using the Regular expression mode:

            No doubt that using my method will be safer !!

            Understood.
            I was just trying to help OP by sticking with his exact problem.
            It’s fine to present more complicated situations in follow-on discussions, as you did.

            1 Reply Last reply Reply Quote 0
            • dr ramaanandD
              dr ramaanand @guy038
              last edited by

              @guy038 The gist of the matter is that parentheses, that is rounded, simple brackets have to be escaped with a backslash like \( and \) or else they will be skipped during any replacement

              Alan KilbornA dr ramaanandD 2 Replies Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @dr ramaanand
                last edited by

                @dr-ramaanand said in CSS not working when I add it to multiple files using the Regular expression mode:

                The gist of the matter is that parentheses…

                Perhaps equally important for possible future readers of this topic is showing a technique to get multiline text into the Replace with box! :-)

                dr ramaanandD 1 Reply Last reply Reply Quote 1
                • dr ramaanandD
                  dr ramaanand @dr ramaanand
                  last edited by dr ramaanand

                  For those who’ve searched online and come here, let me tell you that I had already made the mistake of not escaping the parentheses, just as @guy038 gave as a solution first which was faulty as it skipped adding the parentheses. I had ended up with @media max-width: 480px {. However, you need not fret if you have made the same mistake, just put @media max-width: 480px in the Find field, select the Regular expression mode, put @media \(max-width: 480px\) and hit the Replace in files button and you will end up with the correct result which is @media (max-width: 480px) {

                  1 Reply Last reply Reply Quote 0
                  • dr ramaanandD
                    dr ramaanand @Alan Kilborn
                    last edited by

                    @Alan-Kilborn said in CSS not working when I add it to multiple files using the Regular expression mode:

                    Perhaps equally important for possible future readers of this topic is showing a technique to get multiline text into the Replace with box! :-)

                    Yes, for multiple lines to be added, we have to put Line1\r\nLine2\r\nLine3\r\nLine4 in the Replace in files field to get one line below the other.

                    Alan KilbornA 1 Reply Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @dr ramaanand
                      last edited by

                      @dr-ramaanand said:

                      for multiple lines to be added, we have to put Line1\r\nLine2\r\nLine3\r\nLine4

                      OK, so now any possible benefit of the original technique is probably lost to future readers. :-(

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

                        Hello, @dr-ramaanand and All,

                        See also the last part of this post which exposed a simple solution when you just want to insert a multi-lines text, even in multiple locations, of the curent file, only :

                        https://community.notepad-plus-plus.org/post/98543

                        Best Regards

                        guy038

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