Difference between revisions of "IDE regular expressions/fi"

From Free Pascal wiki
Jump to navigationJump to search
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{IDE_regular_expressions}}
 
{{IDE_regular_expressions}}
  
== Normal regular expression ==
+
= Säännöllinen lauseke =
  
Metacharacters:
+
== Normaali säännöllinen lauseke ==
     \  Quote the next metacharacter
+
 
 +
Erikoismerkit:
 +
     \  Pitää seuraavaa erikoismerkkiä normaalina merkkinä. Tai jos on jokin merkki a-z:n tai A-Z:n
 +
        väliltä niin sillä saattaa olla erikoismerkitys (katso takakenoviivan erikoismerkitykset kohtaa)
 
     ^  Match the beginning of the line
 
     ^  Match the beginning of the line
     .  Match any character (except newline). Example: 'a.c' matches 'abc', 'aBC', 'axc', 'a3c', 'a$c', etc.
+
     .  Sopii mikä tahansa merkki (paitsi uusi rivi). Esimerkiksi: 'a.c':n soveltuvat 'abc', 'aBC',  
 +
        'axc', 'a3c', 'a$c', jne.
 
     $  Match the end of the line (or before newline at the end)
 
     $  Match the end of the line (or before newline at the end)
     |  Alternation
+
     |  Tai
 
     ()  Grouping. For example: (abc)+ matches 'abc' or 'abcabc' or 'abcabcabc' etc.
 
     ()  Grouping. For example: (abc)+ matches 'abc' or 'abcabc' or 'abcabcabc' etc.
     []  Character class
+
     []  Vaihtoehtoisten merkkien joukko. Esimerkiksi [abc], [a-z], [a-zA-Z0-9_]
 +
    [^]  Ei hyväksyttävien merkkien joukko. Esimerkiksi [^a-z]
  
 
Quantifiers:
 
Quantifiers:
Line 48: Line 53:
 
</pre>
 
</pre>
  
 +
== Takakenoviivan erikoismerkitykset ==
 +
 +
Takakenoviivaa ("\" eli backslash-merkkiä) käytetään poistamaan joiltakin merkeiltä kuten pisteeltä (".") poistamaan sen erikoismerkityksen eli silloin se tarkoittaa normaalia pistettä. Toisena merkityksenä sillä on mahdollistaa muutamia erikoismerkityksiä.
 +
 +
<pre>
 +
  \. matches a point '.'
 +
  \d matches a number character '0'..'9'
 +
  \D matches a non number character
 +
  \s matches a space character ' ',#9,#10,#12,#13
 +
  \S matches a non space character
 +
  \w matches a word character 'a'..'z','A'..'Z','0'..'9','_'
 +
  \W matches a non word character
 +
  \b word boundary
 +
  \B not word boundary
 +
  \A begin of line
 +
  \Z end of line
 +
</pre>
  
== Search and Replace with regular expressions ==
+
== Säännöllinen lauseke etsi ja korvaa toiminnoissa ==
  
The find dialogs support regular expressions for finding and replacing. Each found pattern grouped in round brackets can be used by a $1, ..., $9 variable
+
"Etsi" sekä "Etsi ja korvaa" ikkunat tukevat säännöllisiä lausekeita etsinnässä ja korvaamisessa. Each found pattern grouped in round brackets can be used by a $1, ..., $9 variable
  
 
For example:
 
For example:

Latest revision as of 20:05, 10 August 2006

English (en) español (es) suomi (fi) polski (pl)

Säännöllinen lauseke

Normaali säännöllinen lauseke

Erikoismerkit:

   \   Pitää seuraavaa erikoismerkkiä normaalina merkkinä. Tai jos on jokin merkki a-z:n tai A-Z:n 
       väliltä niin sillä saattaa olla erikoismerkitys (katso takakenoviivan erikoismerkitykset kohtaa)
   ^   Match the beginning of the line
   .   Sopii mikä tahansa merkki (paitsi uusi rivi). Esimerkiksi: 'a.c':n soveltuvat 'abc', 'aBC', 
       'axc', 'a3c', 'a$c', jne.
   $   Match the end of the line (or before newline at the end)
   |   Tai
   ()  Grouping. For example: (abc)+ matches 'abc' or 'abcabc' or 'abcabcabc' etc.
   []  Vaihtoehtoisten merkkien joukko. Esimerkiksi [abc], [a-z], [a-zA-Z0-9_]
   [^]   Ei hyväksyttävien merkkien joukko. Esimerkiksi [^a-z]

Quantifiers:

   *      Match 0 or more times
   +      Match 1 or more times
   ?      Match 1 or 0 times
   {n}    Match exactly n times
   {n,}   Match at least n times
   {n,m}  Match at least n but not more than m times

Curly brackets in any other context is treated as a regular character. The ``* is equivalent to {0,}, the ``+ to {1,} and the ``? to {0,1}.

By default, a quantifier is greedy, that means, it will match as many times as possible. To match the minimum number of times possible, append a ``?.

   *?     Match 0 or more times
   +?     Match 1 or more times
   ??     Match 0 or 1 time
   {n}?   Match exactly n times
   {n,}?  Match at least n times
   {n,m}? Match at least n but not more than m times

Simple Syntax

Some IDE dialogs provide a checkbox to enable 'simple syntax'. These regular expressions are shorter for common file name filters.

Technically it does this:

  The following characters are replaced with
  . -> \.
  * -> .*
  ? -> .
  , -> |
  ; -> |
  
  Finally enclose by ^( )$

Takakenoviivan erikoismerkitykset

Takakenoviivaa ("\" eli backslash-merkkiä) käytetään poistamaan joiltakin merkeiltä kuten pisteeltä (".") poistamaan sen erikoismerkityksen eli silloin se tarkoittaa normaalia pistettä. Toisena merkityksenä sillä on mahdollistaa muutamia erikoismerkityksiä.

  \. matches a point '.'
  \d matches a number character '0'..'9'
  \D matches a non number character
  \s matches a space character ' ',#9,#10,#12,#13
  \S matches a non space character
  \w matches a word character 'a'..'z','A'..'Z','0'..'9','_'
  \W matches a non word character
  \b word boundary
  \B not word boundary
  \A begin of line
  \Z end of line

Säännöllinen lauseke etsi ja korvaa toiminnoissa

"Etsi" sekä "Etsi ja korvaa" ikkunat tukevat säännöllisiä lausekeita etsinnässä ja korvaamisessa. Each found pattern grouped in round brackets can be used by a $1, ..., $9 variable

For example:

  • Find expression: a(.*)c
  • Replace expression: A$1C
  • Text: 'abc aLazc'

The $1 will be replaced with the found text, that matches the first bracket.

  • Result: 'AbC ALazC'