regex - Match a Regular Expression by simple 2 cases: -
i'm trying use regex pattern in fpc (free pascal) - more here: http://wiki.freepascal.org/ide_regular_expressions
however! can't determine how match first occurrence (if any) of 3or4 lowercase (a-z) character strand.
i'd proceed trying same expression time allowing upper case & numbers in make 3or4 char strand.
help appreciated! :]
for example (things i've tried + examples):
s := 'my name'; // want 'ame' portion 1st since there exists consecutive string of 3 lowercase chars. // attempts: splitregexpr('[[:alnum:]]{3,4}'); splitregexpr('[a-z]{3,4}'); splitregexpr('[[:alnum:]]{3,4}?'); in response ken white, think right link, no? http://www.gnu-pascal.de/gpc/regex.html understand definitions, fail see how use them create (for example i'm trying do) match patterns , returns them.
here program extracting 3 or 4 lowercase character sequences.
{$apptype console} {$ifdef fpc}{$mode delphi}{$endif} uses regexpr; var expr: tregexpr; begin expr := tregexpr.create; expr.expression := '[a-z]{3,4}'; if expr.exec('my name bunny.') repeat writeln(expr.match[0]); until not expr.execnext; expr.free; readln; end.
Comments
Post a Comment