Re: [fpc-pascal] A Regular Expression failing on the borders of words

2014-04-10 Thread Mattias Gaertner
On Thu, 10 Apr 2014 02:43:41 -0300 luciano de souza luchya...@gmail.com wrote: [...] r.expression := '^(x\s+)*(\([A-E]\))*(\s*.*\.)+(\s+\+.*\b)*(\s+@.*\b)*$'; if r.exec('x (A) Write a report. +ABC +DEF @John @Mary') then The (\s+\+.*\b) matches '+ABC +DEF @John @Mary'. Mattias

Re: [fpc-pascal] A Regular Expression failing on the borders of words

2014-04-10 Thread luciano de souza
Well, I need to study more. I can't understand what is wrong. The match starts with a blank space: \s+. Some string follows: .*. And it ends in the border of word: \b. So, (\s+.*\b)*, for me, should return: +ABC +DEF. If @ is not present, why the rest of the string was matched. My knowledge about

Re: [fpc-pascal] A Regular Expression failing on the borders of words

2014-04-10 Thread Mattias Gaertner
On Thu, 10 Apr 2014 10:05:44 -0300 luciano de souza luchya...@gmail.com wrote: Well, I need to study more. I can't understand what is wrong. The match starts with a blank space: \s+. Some string follows: .*. And it ends in the border of word: \b. So, (\s+.*\b)*, for me, should return: +ABC

Re: [fpc-pascal] A Regular Expression failing on the borders of words

2014-04-10 Thread Graeme Geldenhuys
When in doubt, I always recommend Explain Regex - there are many such online services. Here is one. http://rick.measham.id.au/paste/explain.pl?regex=%5Cd%2B(.%5Cd%2B)%3F(%5BeE%5D%5Cd%2B)%3F Simply paste your regex in the box and click the button. It will then analyse and explain what your

[fpc-pascal] A Regular Expression failing on the borders of words

2014-04-09 Thread luciano de souza
Hello all, This program compiles, but it gives a wrong output. program ertext; {$mode objfpc}{$H+} uses Sysutils, regexpr; var r: TRegexpr; i: integer; BEGIN r := TRegexpr.create; try r.expression := '^(x\s+)*(\([A-E]\))*(\s*.*\.)+(\s+\+.*\b)*(\s+@.*\b)*$'; if r.exec('x (A) Write a report.