CSS not working when I add it to multiple files using the Regular expression mode
-
@guy038 merci beaucoup!
-
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
-
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 thisLisp
module which converts any roman number into its decimal equivalent numberFor instance, in
Lisp
, with the program below and the question(trad 'MCMXCV)
, it would return1995
( 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 largerLisp
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 -
-
@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. -
@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 -
@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! :-)
-
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) {
-
@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. -
@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. :-(
-
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