Question

I'm trying to turn free-form text into something more structured. I have a complex pattern that matches the great majority (well above the minimum acceptable limit) of the data available, and I'd like to use that to assist in structuring the data, rather than parsing the text character-by-character. The problem that I've just run into is that Oracle does not seem to have any way of handling capture groups (unless I somehow missed it?).

For example,my expression has quite a few named capture groups such as ((?<runit_ID>\d+)-) and (STAT_N|STTN|STAT|STN) ?(?<STAT>\w+). The codebase is written entirely in PL/SQL so I can't use C# or something else to refer to the capture groups by name. How do people work around this in PL/SQL?

Was it helpful?

Solution

Assuming you are using Oracle 10g or higher, you can use REGEXP_REPLACE with backreferences.

See examples in the Oracle docs for REGEXP_REPLACE and in this article at regular-expressions.info.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top