Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-02

Pascal and regexes

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

I'm using TRegex to process stuff that I'm receiving from an RS232 port, actually connected to a Tek 'scope. If I have an incoming message like

ACQ:08080E3150;

and apply a regex such as ACQ:(..){5}; I get a single match which is 50.

If instead I use ACQ:(..)(..){4}; I get two matches 08 and 50, while if I use ACQ:(..)((..){4}); I get 08 and 080E3150.

Can anybody see a way of either specifying a regex where the number of matches is the same as the number of subexpressions matched by a value in braces etc., or of pulling it out of the regex object after the match? This obviously isn't significant in the above case where there's a small amount of input, but it would be nice to be able to match a fixed-size block of data by using something like (..}{512}.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]