notepad++ REGEX how to find matched string and keep it (delete all surrounding text) [duplicate] - regex

This question already has answers here:
Delete all content but keeping matched
(1 answer)
Can't use ^ to say "all but"
(4 answers)
Closed 2 years ago.
I am trying to use regex function to find the following string AAA and delete everything else (except the ending part of this string)
Example:
eenqowtnorynwny55w4oynw AAABBB ewtenoqtn3oyn AAACCC 4et3o4ny3ny AAADDD 3to3n4yon45yo
wetn3o4tn3o5yn AAAZZZ wn3otn3on AAANNN
expected outpout
AAABBB
AAACCC
AAADDD
AAAZZZ
AAANNN

Related

Regex for substring match [duplicate]

This question already has answers here:
Regex for string contains?
(5 answers)
Closed 7 months ago.
I have list of strings
03000_textbox (57447),
03990_textbox (57499),
03000_textnewbox (57447)
I want to use regex to capture 1st and 2nd elements of list.
Anything that contains substring textbox i.e.
03000_textbox (57447)
03990_textbox (57499)
Here is the regex you're looking for :
[0-9]+_textbox \([0-9]+\)
Live sample : https://regex101.com/r/2oiwcF/1
Don't forget to put a global (g) flag so you can get every match and loop into.

Extract text between slashes which contain '=' [duplicate]

This question already has answers here:
filter a List according to multiple contains
(3 answers)
Closed 3 years ago.
I want a regex to extract the text between slashes which contain an equals '='
data/xx/yy/zz/date=20190506/xxx.json
-> date=20190506
Regex not needed.
val str = "data/x=x/yy/zz/date=20190506/xxx.json" //example string (modified)
str.split("/").filter(_.contains('='))
//res0: Array[String] = Array(x=x, date=20190506)

remove characters including | but only up to (not including) > [duplicate]

This question already has answers here:
Carets in Regular Expressions
(2 answers)
Closed 3 years ago.
in the pattern
<Blast>uce-506_drosophila_albomicans |uce506</BlastOutput_query-def>
I'm trying to remove |* up to (but not including) <
I tried (but doesn't achieve it)
sed 's/^|[^<]*//g' dataset2.fasta.xml >dataset2_2.fasta.xml
Single caret ^ means "start at the beginning of the line." Remove it:
sed 's/|[^<]*//g'

regex to extract before colon and between quotes [duplicate]

This question already has answers here:
Regex to match key in YAML
(3 answers)
Closed 4 years ago.
What regexp to use to match before colon and between quotes?
e.g
"This text only":"bla bla bla"
↓
This text only
I need this to extract only key fields in yaml.
"(.*)"\:"(.*)" shall provide you your both the key and value test link
If only the key is needed then:
"(.*)".* shall get you the key only part

Regex - get first occurrence [duplicate]

This question already has answers here:
My regex is matching too much. How do I make it stop? [duplicate]
(5 answers)
Closed 5 years ago.
I have the following string:
EN=sdfsdf, CN=User Name, CN=Users, DC=domain, DC=co, DC=il
I need to return the first string that starts with "CN=" and ends with an ",".
In this case I need to return "User Name".
'CN=.*,'
returns
"CN=User Name, CN=Users, DC=domain, DC=co,"
How can I get the just the first occurrence?
You will need the non-greedy option in your Regex:
CN=.*?,
See also How can I write a regex which matches non greedy?