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


Ignore:
Timestamp:
Jan 23, 2014 4:34:44 PM (9 months ago)
Author:
natman
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • es:Documentation/Pattern matching

    v1 v1  
     1[[TranslatedPages(revision=1)]] 
     2 
     3== Plantilla de Búsqueda AmigaDOS == 
     4 
     5El uso de signos especiales en plantillas le permite definir búsqueda muy potentes. 
     6Los signos especiales se muestran en la siguiente lista. 
     7 
     8 
     9  `?`   Coincidencia de un sólo carácter 
     10      así Y?M localiza YAM, YUM, Y@M etc. 
     11 
     12  `#`   Coincidencia de cero o más ocurrencias del item siguiente 
     13      así Y#AM localiza YM, YAM, YAAM, YAAAM etc. 
     14 
     15  `#?`  Coincidencias al completo (incluso nada!) 
     16      así #?YAM#? localiza cualquier cadena que contenga "YAM" 
     17 
     18  `%`   Coincidencias con campo vacío. No es muy útil, pero puede utilizarlo para buscar mensajes con el "Asunto:" de la cabecera en blanco 
     19 
     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 ... 
     22 
     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 
     25 
     26  `-`   Indicates a range, so ![0-9] matches any single digit and #![0-9] matches any integral number. 
     27 
     28  `~`   Means NOT, referring to the whole expression following, 
     29      so ~Re: matches any string that does not start with "Re:" 
     30 
     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". 
     33 
     34  `'`  Removes the meaning of a special character.  For instance, 
     35      '#'? matches the literal string "#?" 
     36 
     37 
     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) 
     40 
     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#?) 
     47 
     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#?) 
     52 
     53Another case -- suppose we want to find all the strings that 
     54include '''YAM''' but do not start with "Re:".  So we try: (~Re!:)YAM#? 
     55 
     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: 
     63(~Re!:|%)YAM#? 
     64 
     65Question for computer buffs: what does ~((~#?YAM#?)|(~#?MUI#?)) 
     66mean? :-)