Avatar billede snorga Nybegynder
07. november 2000 - 22:03 Der er 6 kommentarer og
1 løsning

regulære udtryk (regular expressions)

regulære udtryk (regular expressions)

En af mine venner fortalte mig om denne smarte ting.

Er der nogen der ved om der findes funktioner i delphi, til at under sætte dette?

Søgte på det i hjælpen men fandt kun noget under Menu|søgning..
Avatar billede retep Nybegynder
07. november 2000 - 23:51 #1
Fandt dette i hjælpen. Måske kan du bruge det? Ellers må du afvise mit svar ;)

Regular expressions are characters that customize a search string. Delphi recognizes these regular expressions:

Character    Description

^    A circumflex at the start of the string matches the start of a line.
$    A dollar sign at the end of the expression matches the end of a line.
.    A period matches any character.
*    An asterisk after a string matches any number of occurrences of that string followed by any characters, including zero characters. For example, bo* matches bot, bo and boo but not b.
+    A plus sign after a string matches any number of occurrences of that string followed by any characters except zero characters. For example, bo+ matches boo, and booo, but not bo or be.

[ ]    Characters in brackets match any one character that appears in the brackets, but no others. For example [bot] matches b, o, or t.
[^]    A circumflex at the start of the string in brackets means NOT. Hence, [^bot] matches any characters except b, o, or t.
  •     A hyphen within the brackets signifies a range of characters. For example, [b-o] matches any character from b through o.
{ }    Braces group characters or expressions. Groups can be nested, with a maximum number of 10 groups in a single pattern.

  \\      A backslash before a wildcard character tells the Code Editor to treat that character literally, not as a wildcard. For example, \\^ matches ^ and does not look for the start of a line.

Note:    Delphi also supports Brief regular expressions if you are using Brief keystroke mappings.

Use these symbols to produce Brief regular expressions:

<    A less than at the start of the string matches the start of a line.

%    A percent sign at the start of the string matches the start of a line.
$    A dollar sign at the end of the expression matches the end of a line.
>    A greater than at the end of the expression matches the end of a line.
  ?    A question mark matches any single character.
@    An at sign after a string matches any number of occurrences of that string followed by any characters, including zero characters. For example, bo@ matches bot, boo, and bo.

+    A plus sign after a string matches any number of occurrences of that string followed by any characters, except zero characters. For example, bo+ matches bot and boo, but not b or bo.
  |    A vertical bar matches either expression on either side of the vertical bar. For example, bar|car will match either bar or car.
  ~    A tilde matches any single character that is not a member of a set.
[ ]    Characters in brackets match any one character that appears in the brackets, but no others. For example [bot] matches b, o, or t.

[^]    A circumflex at the start of the string in brackets means NOT. Hence, [^bot] matches any characters except b, o, or t.
  •     A hyphen within the brackets signifies a range of characters. For example, [b-o] matches any character from b through o.
{ }    Braces group characters or expressions. Groups can be nested, with the maximum number of 10 groups in a single pattern.
  \\      A backslash before a wildcard character tells the IDE to treat that character literally, not as a wildcard. For example, \\^ matches ^ and does not look for the start of a line.
Avatar billede snorga Nybegynder
08. november 2000 - 07:32 #2
Det har jeg også fundet, det forklare ikke om der er funktioner i delphi som man kan bruge :-(
(Og hvad de så hedder..)
Avatar billede retep Nybegynder
08. november 2000 - 15:50 #3
Faldt lige over denne her:

http://www.delphicity.net/component.cfm?componentid=239

IKKE testet!
Avatar billede lrj Nybegynder
09. november 2000 - 17:58 #4
Den side fra hjælpen omhandler Delphi\'s editor, hvor man kan bruge reg exp. til at søge i sin source :=)

Der findes også andre implementationer:
http://home.clear.net.nz/pages/niche/RegularExpression/
http://ourworld.compuserve.com/homepages/neil_butterworth/RegExpUnit.htm - download: http://ourworld.compuserve.com/homepages/neil_butterworth/odregexpunit.pas

Begge er med fuld source, og vistnok gratis - jeg har dog ikke kigget på dem.
Avatar billede snorga Nybegynder
09. november 2000 - 19:20 #5
Jep det ved jeg.. der fra \"Søgte på det i hjælpen men fandt kun noget under Menu|søgning.. \"

Jeg fandt også en selv, men det var uden kode, så Point til dig :)
Avatar billede lrj Nybegynder
09. november 2000 - 20:26 #6
*stående bifald*

*bukker*

\"Og mange tak til google.com - uden den ville det aldrig kunnet have lade sig gøre. Det var bare at søge på \"regular expression delphi\" og så kigge de første 10 links igennem. Alt for sejt. Tak igen Google :)\"

*bukker og går ud af scenen*
Avatar billede snorga Nybegynder
10. november 2000 - 07:46 #7
<G>
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester