I have a filename (or basically a string, since it doesnt need to have an extension, can have spaces though) that is encapsulated by quotes in a string of the following format:
attachment; filename="Some filename.ext"
So basically my approach (java) was to take a Matcher with a Pattern:
Matcher mat = Pattern.compile("attachment; filename=\"([\\w\\.]+)\"").matcher(filename);
But myMatcher.find() returns False
Where does the RegEx go wrong?
\\wdoes not match spaces. Also, you don’t need to (but may) escape the.inside character classes. If you just want to allow spaces, add them to the character class:If there maybe more characters than spaces, letters, digits, periods and underscores, you might want to use a negative character class instead, that just takes in everything until the next quote: