Changes between Initial Version and Version 1 of es:Documentation/Pattern matching

Jan 23, 2014, 4:34:44 PM (4 years ago)
Emilio Jimenez


  • es:Documentation/Pattern matching

    v1 v1  
     3== Plantilla de Búsqueda AmigaDOS ==
     5El uso de signos especiales en plantillas le permite definir búsqueda muy potentes.
     6Los signos especiales se muestran en la siguiente lista.
     9  `?`   Coincidencia de un sólo carácter
     10      así Y?M localiza YAM, YUM, Y@M etc.
     12  `#`   Coincidencia de cero o más ocurrencias del item siguiente
     13      así Y#AM localiza YM, YAM, YAAM, YAAAM etc.
     15  `#?`  Coincidencias al completo (incluso nada!)
     16      así #?YAM#? localiza cualquier cadena que contenga "YAM"
     18  `%`   Coincidencias con campo vacío. No es muy útil, pero puede utilizarlo para buscar mensajes con el "Asunto:" de la cabecera en blanco
     20  `()`  Round brackets are used to group characters and expressions and show how to evaluate the expression.  Use them freely!
     21      Thus #(Re!:)YAM matches YAM, Re:YAM, Re:Re:YAM ...
     23  `[]`  Square brackets are used to indicate a list of alternatives
     24      so [YAM] matches any of the single letters Y, A or M but not YAM
     26  `-`   Indicates a range, so ![0-9] matches any single digit and #![0-9] matches any integral number.
     28  `~`   Means NOT, referring to the whole expression following,
     29      so ~Re: matches any string that does not start with "Re:"
     31  `|`   Means OR, referring to the expressions either side.  You have to enclose the whole expression in round brackets:
     32      e.g.  (#?YAM#?|#?MUI#?) finds strings including either "YAM" or "MUI".
     34  `'`  Removes the meaning of a special character.  For instance,
     35      '#'? matches the literal string "#?"
     38'''ATENCION! ''' No es tan fácil como parece!  Por ejemplo, construyamos un filtro
     39que nos busque referencias a YAM o YAM2, pero que no contenga YAM1. Intente esto: #?YAM(~1)
     41What does this say to do?  Reading a new string from the left, look
     42for the sequence '''YAM'''.  If you find it, look at the following part: is it
     43equal to "1"?  If not, you've got a match.  The trouble is, "1.3.5" isn't
     44equal to "1" (it's too long), so YAM1.3.5 is included though we don't
     45want it.  The solution is to make it clear that the string following
     46"YAM" must not start with a "1".  So try: #?YAM(~1#?)
     48This gets rid of 1.3.5 alright, but there's still a problem:
     49sometimes, people insert a space between YAM and the version number and
     50sometimes not.  So references to '''YAM 1''' are still included.  So we must
     51say that any number of spaces may be present, like this: #?YAM# (~1#?)
     53Another case -- suppose we want to find all the strings that
     54include '''YAM''' but do not start with "Re:".  So we try: (~Re!:)YAM#?
     56This says to begin by comparing the start of the string to "Re:".
     57If we get a match, that string is discarded; if not, we look in the
     58rest of the string to find "YAM".  So what happens if the string starts
     59with "YAM"?  The first letter isn't '''R''', so the NOT condition is
     60satisfied.  But we've done the Y now, so we don't find the string '''YAM'''!
     61To sort this out, we have to explain that the string in front of "YAM"
     62may be the null string (so that's what it is for!).  Like this:
     65Question for computer buffs: what does ~((~#?YAM#?)|(~#?MUI#?))
     66mean? :-)