Skip to content

es:Documentation Pattern matching

Jens Maus edited this page Feb 13, 2017 · 1 revision

Plantilla de Búsqueda AmigaDOS

El uso de signos especiales en plantillas le permite definir búsqueda muy potentes. Los signos especiales se muestran en la siguiente lista.

? Coincidencia de un sólo carácter así Y?M localiza YAM, YUM, Y@M etc.

# Coincidencia de cero o más ocurrencias del item siguiente así Y#AM localiza YM, YAM, YAAM, YAAAM etc.

#? Coincidencias al completo (incluso nada!) así #?YAM#? localiza cualquier cadena que contenga "YAM"

% Coincidencias con campo vacío. No es muy útil, pero puede utilizarlo para buscar mensajes con el "Asunto:" de la cabecera en blanco

() Round brackets are used to group characters and expressions and show how to evaluate the expression. Use them freely! Thus #(Re!:)YAM matches YAM, Re:YAM, Re:Re:YAM ...

[] Square brackets are used to indicate a list of alternatives so YAM matches any of the single letters Y, A or M but not YAM

- Indicates a range, so !0-9 matches any single digit and #!0-9 matches any integral number.

~ Means NOT, referring to the whole expression following, so ~Re: matches any string that does not start with "Re:"

| Means OR, referring to the expressions either side. You have to enclose the whole expression in round brackets: e.g. (#?YAM#?|#?MUI#?) finds strings including either "YAM" or "MUI".

' Removes the meaning of a special character. For instance, '#'? matches the literal string "#?"

*ATENCION! * No es tan fácil como parece! Por ejemplo, construyamos un filtro que nos busque referencias a YAM o YAM2, pero que no contenga YAM1. Intente esto: #?YAM(~1)

What does this say to do? Reading a new string from the left, look for the sequence YAM. If you find it, look at the following part: is it equal to "1"? If not, you've got a match. The trouble is, "1.3.5" isn't equal to "1" (it's too long), so YAM1.3.5 is included though we don't want it. The solution is to make it clear that the string following "YAM" must not start with a "1". So try: #?YAM(~1#?)

This gets rid of 1.3.5 alright, but there's still a problem: sometimes, people insert a space between YAM and the version number and sometimes not. So references to YAM 1 are still included. So we must say that any number of spaces may be present, like this: #?YAM# (~1#?)

Another case -- suppose we want to find all the strings that include YAM but do not start with "Re:". So we try: (~Re!:)YAM#?

This says to begin by comparing the start of the string to "Re:". If we get a match, that string is discarded; if not, we look in the rest of the string to find "YAM". So what happens if the string starts with "YAM"? The first letter isn't R, so the NOT condition is satisfied. But we've done the Y now, so we don't find the string YAM! To sort this out, we have to explain that the string in front of "YAM" may be the null string (so that's what it is for!). Like this: (~Re!:|%)YAM#?

Question for computer buffs: what does ((#?YAM#?)|(~#?MUI#?)) mean? :-)


Getting Started


Advanced use of YAM



Clone this wiki locally