I want to search for a line which starts with lets say a and ends with z. In-between any number of any character开发者_高级运维 can come. How can i write an expression for this? ( I dont want to explicity mention any digits, any special chars, any alphabets ) I don't to do something like ^[0-9,a-z,A-Z,list all special chars]*$.
How about:
^a.*z$
.
is the regex metacharacter that matches anything.
*
is a greedy modifier that repeats the previous item 0 or more times, trying for the biggest number of matches first, followed by smaller permutations until the preceding item cannot be matched at all, which will in fact, still make the overall regex match.
^a.*z$
If you want to change it from "any number (including zero) of characters" to "one or more characters", then change the * to +.
精彩评论