Reputation: 5086
Given the following string which may appear any number of times across various documents and in various different formats, I want to pull out the part between the quotes. I Only want strings which meet the following conditions. Starts and ends with " (between two quotes) and has 1 or more dots (.) within the string.
@CheckWith(value = PasswordCheck.class, message = "validation.password.blah.foo")
The following regex gives me the first three parts of the string validation.password.blah but misses the .foo
(\")([a-zA-Z]{1,}\.{1}){1,}
Upvotes: 0
Views: 232
Reputation: 65851
If you have egrep
(or grep -E
), you can use
"([a-zA_Z]+\.)+[a-zA-Z]+"
(quotes are part of the regex, escape if needed).
Upvotes: 0
Reputation: 16714
I think the regex you are looking for is this: "[a-zA-Z]+(\.[a-zA-Z]+)+
You should have in mind that it wont include last "
and will only accept letters between the dots.
Upvotes: 0
Reputation: 208635
Try the following:
"([a-zA-Z]{1,}\.[a-zA-Z.]{1,})"
Note that instead of {1,}
you can usually use +
, but I'm not sure if grep supports that without an extended option.
Explanation:
" # match a literal '"' character
( # start capture group
[a-zA-Z]{1,} # one or more letters
\. # match a literal '.' character
[a-zA-Z.]{1,} # one or more letters or '.' characters
) # end capture group
" # match a literal '"' character
Upvotes: 1