home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.privacy      Discussing privacy, laws, tinfoil hats      112,125 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 110,537 of 112,125   
   D to All   
   Regular expressions (regex) (1/3)   
   10 Aug 24 21:09:14   
   
   From: noreply@mixmin.net   
      
   40tude Dialog > Help [F1] > Index > Regular expressions:   
   >Regular Expressions   
   >Introduction   
   >Regular Expressions are a widely-used method of specifying patterns of   
   >text to search for. Special metacharacters allow You to specify, for   
   >instance, that a particular string You are looking for occurs at the   
   >beginning or end of a line, or contains n recurrences of a certain   
   >character.   
   >Regular expressions look ugly for novices, but really they are very   
   >simple, handy and powerful tool.   
   >Simple matches   
   >Any single character matches itself, unless it is a metacharacter with a   
   >special meaning described below.   
   >A series of characters matches that series of characters in the target   
   >string, so the pattern "bluh" would match "bluh'' in the target string.   
   >You can cause characters that normally function as metacharacters or   
   >escape sequences to be interpreted literally by 'escaping' them by   
   >preceding them with a backslash "\", for instance: metacharacter "^"   
   >match beginning of string, but "\^" match character "^", "\\" match "\"   
   >and so on.   
   >Examples:   
   >  foobar          matches string 'foobar'   
   >  \^FooBarPtr     matches '^FooBarPtr'   
   >Escape sequences   
   >Characters may be specified using a escape sequences syntax much like   
   >that used in C and Perl: "\n'' matches a newline, "\t'' a tab, etc. More   
   >generally, \xnn, where nn is a string of hexadecimal digits, matches the   
   >character whose ASCII value is nn. If You need wide (Unicode) character   
   >code, You can use '\x{nnnn}', where 'nnnn' - one or more hexadecimal   
   >digits.   
   >  \xnn      char with hex code nn   
   >  \x{nnnn}  char with hex code nnnn (one byte for plain text and two bytes   
   >            for Unicode)   
   >  \t        tab (HT/TAB), same as \x09   
   >  \n        newline (NL), same as \x0a   
   >  \r        car.return (CR), same as \x0d   
   >  \f        form feed (FF), same as \x0c   
   >  \a        alarm (bell) (BEL), same as \x07   
   >  \e        escape (ESC), same as \x1b   
   >Examples:   
   >  foo\x20bar   matches 'foo bar' (note space in the middle)   
   >  \tfoobar     matches 'foobar' predefined by tab   
   >Character classes   
   >You can specify a character class, by enclosing a list of characters in   
   >[], which will match any one character from the list.   
   >If the first character after the "['' is "^'', the class matches any   
   >character not in the list.   
   >Examples:   
   >  foob[aeiou]r   finds strings 'foobar', 'foober' etc. but not 'foobbr',   
   >                 'foobcr' etc.   
   >  foob[^aeiou]r  find strings 'foobbr', 'foobcr' etc. but not 'foobar',   
   >                 'foober' etc.   
   >Within a list, the "-'' character is used to specify a range, so that   
   >a-z represents all characters between "a'' and "z'', inclusive.   
   >If You want "-'' itself to be a member of a class, put it at the start or   
   >end of the list, or escape it with a backslash. If You want ']' you may   
   >place it at the start of list or escape it with a backslash.   
   >Examples:   
   >  [-az]      matches 'a', 'z' and '-'   
   >  [az-]      matches 'a', 'z' and '-'   
   >  [a\-z]     matches 'a', 'z' and '-'   
   >  [a-z]      matches all twenty six small characters from 'a' to 'z'   
   >  [\n-\x0D]  matches any of #10,#11,#12,#13.   
   >  [\d-t]     matches any digit, '-' or 't'.   
   >  []-a]      matches any char from ']'..'a'.   
   >Metacharacters   
   >Metacharacters are special characters which are the essence of Regular   
   >Expressions. There are different types of metacharacters, described below.   
   >Metacharacters - line separators   
   >  ^      start of line   
   >  $      end of line   
   >  \A     start of text   
   >  \Z     end of text   
   >  .      any character in line   
   >Examples:   
   >  ^foobar     matches string 'foobar' only if it's at the beginning of line   
   >  foobar$     matches string 'foobar' only if it's at the end of line   
   >  ^foobar$    matches string 'foobar' only if it's the only string in line   
   >  foob.r      matches strings like 'foobar', 'foobbr', 'foob1r' and so on   
   >The "^" metacharacter by default is only guaranteed to match at the   
   >beginning of the input string/text, the "$" metacharacter only at the end.   
   >Embedded line separators will not be matched by "^'' or "$''.   
   >You may, however, wish to treat a string as a multi-line buffer, such that   
   >the "^'' will match after any line separator within the string, and "$''   
   >will match before any line separator. You can do this by switching On the   
   >modifier /m.   
   >The \A and \Z are just like "^'' and "$'', except that they won't match   
      
   [continued in next message]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca