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

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)

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.

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

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

find a substring after the last backslash with regex [duplicate]

This question already has answers here:
Getting the last backslash in a filepath via regex
(3 answers)
Find the last substring after a character
(4 answers)
Closed 4 years ago.
I need to find the substring after the last \ in the sting (path to file, windows).
I suppose that an elegant pythonic way should be possible (without counting "\" or writing a regression method).
str1 = 'qwerty\\asd\\zxc\x\\c'
str2 = 'zz\\z\\x\\c\\v\\b\\n\\m\\m2m\\m3m'
How to edit this line of code?
found_name = re.findall(r'\\(.*?)', mystr)
Currently it returns all after the fist back slash.
This doesn't require a regex, just use split:
>> str1 = 'qwerty\\asd\\zxc\x\\c'
>> str1.split(r'\\')[-1]
'c'
If you have to use regex for some reason then use:
>>> re.findall(r'.*\\(.*)$', str1)
['c']

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 to match all character groups in a string [duplicate]

This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 5 years ago.
I need a regex to match the groups of characters in a string.
For example this is-a#beautiful^day.
Should result in the following list: this, is, a, beautiful, day.
As a mention I don't know how long the string is or by what characters the words are separated.
Any ideas? I have no clue how to build a regex for this.
If you want find all groups of letters:
import re
string = "this is-a#beautiful^day"
list = re.findall(r'[A-Za-z]+', string)
print list
['this', 'is', 'a', 'beautiful', 'day']