Tuesday, April 27, 2010

Wild Card characters

A wildcard character is a character that may be substituted for any of a defined subset of all possible characters. In computer (software) technology, a wildcard character can be used to substitute for any other character or characters in a string.
For ex:
*.jpg
matches any text which end with .jpg. You can also specify brackets with characters, as in:

*.[ch]pp
matches any text which ends in .cpp or .hpp. Altogether very similar to regular expressions.
The * means match zero or more of anything in wildcards. As we learned, we do this is regular expression with the punctuation mark and the * quantifier. This gives:

.*
Also remember to convert any punctuation marks from wildcards to be backslashified.
The ? means match any character but do match something. This is exactly what the punctuation mark does.

No comments:

Post a Comment