expression for specific words
-
So I got this expression
^.*\(.*?\).*\R It's for removing all lines containing parenthesis. But how do I alter it to only target lines that say (music playing) and (ominous music playing)?
-
@kracovwolf said in expression for specific words:
s expression ^.(.?).*\R
I think something got lost when posting what you tried to the forums.
The expression was probably
^.*\(.?\).*\R
which will remove lines that contain either()
or(.)
where the dot is any character.It’s for removing all lines containing parenthesis. But how do I alter it to only target lines that say (music playing) and (ominous music playing)?
Try this:
^.*\((music playing|ominous music playing)\).*\R
You can make it a little more compact using
^.*\((ominous )?music playing\).*\R
A
\(
or\)
says to match a parentheses in the text, -
@mkupper
isn’t there a better wildcard to also target other ones like suspenseful music playing, etc? -
how do I also include eerie music, heroic music, etc?
-
@kracovwolf said in expression for specific words:
how do I also include eerie music, heroic music, etc?
It sounds like you want to match lines that contain the word
music
. Assuming this is correct, the regular expression(?i-s).*?music.*
will match any line that contains that word.EXPLANATION:
- The
(?i-s)
flag at the beginning makes.
not match newline, and turns ignorecase on (I’m assuming you would like to matchMusic
andMUSIC
as well asmusic
) .*?music
consumes all characters in a line until the wordmusic
.*
consumes the rest of the characters in the line
REFERENCES: https://npp-user-manual.org/docs/searching/#regular-expressions
- The
-
@Mark-Olson no, this is in subtitle files. so it has to be strictly “music playing” or “(# music playing)”. How do I do that instead, I don’t know about spacing between the words. this?
(?i-s).*?music playing.*
-
@kracovwolf
\s+
matches any number of whitespace characters.I’m not going to give you any more hints on basic regex usage - I will once again recommend that you read the user manual’s topic on regular expressions.
While learning regular expressions may be slow going (it took me a long time to get where I am now), believe me when I say that (1) it is worth the effort, and (2) you can’t get there by asking others for the answer.
-
This post is deleted!